-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 710148a
Showing
9 changed files
with
288 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
.venv |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
|
||
|
||
# To learn more about how to use Nix to configure your environment | ||
# see: https://developers.google.com/idx/guides/customize-idx-env | ||
{ pkgs, ... }: { | ||
# Which nixpkgs channel to use. | ||
channel = "stable-23.11"; # or "unstable" | ||
# Use https://search.nixos.org/packages to find packages | ||
packages = [ pkgs.python3 ]; | ||
idx = { | ||
# Search for the extensions you want on https://open-vsx.org/ and use "publisher.id" | ||
extensions = [ "ms-python.python" ]; | ||
workspace = { | ||
# Runs when a workspace is first created with this `dev.nix` file | ||
onCreate = { | ||
install = | ||
"python -m venv .venv && curl -sSL https://install.python-poetry.org | python -"; | ||
}; | ||
# To run something each time the environment is rebuilt, use the `onStart` hook | ||
}; | ||
# Enable previews and customize configuration | ||
previews = { | ||
enable = true; | ||
previews = { | ||
web = { | ||
command = [ "./devserver.sh" ]; | ||
env = { PORT = "$PORT"; }; | ||
manager = "web"; | ||
}; | ||
}; | ||
}; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Flask | ||
|
||
A Flask starter template as per the docs: https://flask.palletsprojects.com/en/3.0.x/quickstart/#a-minimal-application |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#!/bin/sh | ||
export PATH="$HOME/.local/bin:$PATH" | ||
|
||
poetry install | ||
source .venv/bin/activate | ||
|
||
if ! grep -q "$PATH" /home/user/.bashrc; then | ||
echo 'export PATH="$HOME/.local/bin:$PATH"' >> /home/user/.bashrc | ||
fi | ||
|
||
python -m flask --app src/main run -p $PORT --debug |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
[tool.poetry] | ||
name = "python-flask" | ||
version = "0.1.0" | ||
description = "Start a simple web app with the Flask framework for Python" | ||
authors = ["Google LLC"] | ||
packages = [{include = "src"}] | ||
|
||
[tool.poetry.dependencies] | ||
python = "^3.11" | ||
Flask = "^3.0.1" | ||
|
||
[tool.poetry.scripts] | ||
app = 'src.main:main' | ||
|
||
[build-system] | ||
requires = ["poetry-core"] | ||
build-backend = "poetry.core.masonry.api" |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>Hello World</title> | ||
</head> | ||
|
||
<body> | ||
<h1>Hello World</h1> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import os | ||
|
||
from flask import Flask, send_file | ||
|
||
app = Flask(__name__) | ||
|
||
@app.route("/") | ||
def index(): | ||
return send_file('index.html') | ||
|
||
""" Notify receives a GET message | ||
""" | ||
@app.route("/notify") | ||
def notify(): | ||
# Get query params | ||
name = request.args.get('name') | ||
|
||
# Return a JSON response | ||
return jsonify({'name': name}) | ||
|
||
""" Notify receives a POST message | ||
""" | ||
@app.route("/notify_post", methods=['POST']) | ||
def notify_post(): | ||
# | ||
return jsonify({'name': name}) | ||
|
||
|
||
def main(): | ||
app.run(port=int(os.environ.get('PORT', 9005))) | ||
|
||
if __name__ == "__main__": | ||
main() |