diff --git a/app.py b/app.py deleted file mode 100755 index d7bc2c4..0000000 --- a/app.py +++ /dev/null @@ -1,4 +0,0 @@ -from src import app - -if __name__ == "__main__": - app.run() diff --git a/debug.sh b/debug.sh index e0dc617..34121d8 100755 --- a/debug.sh +++ b/debug.sh @@ -1,3 +1,7 @@ #!/bin/sh -venv/bin/python -m flask run --debug -h 192.168.5.3 +venv/bin/python -m flask \ + --app src \ + run \ + --debug \ + -h 192.168.5.3 diff --git a/src/__init__.py b/src/__init__.py index 6784035..14aa9e6 100644 --- a/src/__init__.py +++ b/src/__init__.py @@ -8,20 +8,18 @@ from pygments import formatters, highlight, lexers import markdown from src import ( - # tango_controller, utils, config, ) +# TODO: Put the creation of the Flask application into a function +# https://flask.palletsprojects.com/en/3.0.x/tutorial/factory/ +# def create_app() -> flask.Flask: app = Flask( __name__, template_folder="../templates", static_folder="../static", ) -# app.register_blueprint(tango_controller.bp) - -# Edit -# Create file def get_tree() -> dict: diff --git a/src/utils.py b/src/utils.py new file mode 100644 index 0000000..ae594fe --- /dev/null +++ b/src/utils.py @@ -0,0 +1,9 @@ +# ERRORS ###################################################################### + +def err(message: str, code: int): + return {"error": message}, code + + +ERR_500 = err("Internal server error", 500) +ERR_403 = err("Not authorized", 403) +ERR_404 = err("Not found", 404)