fix: App organization improvement

This commit is contained in:
Dendy 2024-02-24 07:39:22 +01:00
parent abc380aa81
commit 4a525457a6
4 changed files with 17 additions and 10 deletions

4
app.py
View File

@ -1,4 +0,0 @@
from src import app
if __name__ == "__main__":
app.run()

View File

@ -1,3 +1,7 @@
#!/bin/sh #!/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

View File

@ -8,20 +8,18 @@ from pygments import formatters, highlight, lexers
import markdown import markdown
from src import ( from src import (
# tango_controller,
utils, utils,
config, 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( app = Flask(
__name__, __name__,
template_folder="../templates", template_folder="../templates",
static_folder="../static", static_folder="../static",
) )
# app.register_blueprint(tango_controller.bp)
# Edit
# Create file
def get_tree() -> dict: def get_tree() -> dict:

9
src/utils.py Normal file
View File

@ -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)