Aggiunta funzione templates

This commit is contained in:
2026-02-19 13:29:03 +01:00
parent e282f19de0
commit 5f8fb41787
2 changed files with 13 additions and 0 deletions

12
app.py
View File

@@ -15,6 +15,18 @@ def home():
html += "<a href=\"/doc.html\">Documentazione</a>" html += "<a href=\"/doc.html\">Documentazione</a>"
return html, 200 return html, 200
@app.route("/<path:filename>", methods=["GET"])
def template(filename):
if not filename.endswith(".html"):
return "File non valido", 404
try:
read_file = open(f"templates/{filename}", "r")
content = read_file.read()
read_file.close()
return content, 200
except FileNotFoundError:
return "File non trovato", 404
@app.route("/compiti", methods=["GET"]) @app.route("/compiti", methods=["GET"])
def get_compiti(): def get_compiti():
return jsonify(compiti), 200 return jsonify(compiti), 200

View File

@@ -0,0 +1 @@
haiiiii :3