simple webpage

This commit is contained in:
SowinskiBraeden committed 2025-03-13 11:52:46 -07:00
1 parent f366a6a679
commit b3c522f9c6
12 files changed
+186 -1050

No files matched your search

+25
View File
@@ -0,0 +1,25 @@
#!/usr/bin/env python3
from flask import Flask, Response
from flask import render_template
import os
app = Flask(__name__)
def root_dir():
return os.path.abspath(os.path.dirname(__file__))
def get_file(filename):
try:
src = os.path.join(root_dir(), filename)
return open(src).read()
except IOError as exc:
return str(exc)
@app.route("/", methods=["GET"])
def index() -> str:
return render_template("index.html")
@app.route("/boards/<boardID>", methods=["GET"])
def loadBoard(boardID: str) -> str:
path = os.path.join(root_dir(), f"boards/{boardID}.txt")
return Response(get_file(path), mimetype="text/plain")