From 1dac1ee189bdcf70a5dd933d5f6a69a15d5a8d7e Mon Sep 17 00:00:00 2001 From: jwansek Date: Tue, 2 Feb 2021 12:24:06 +0000 Subject: added the program files for the first time --- app.py | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 app.py (limited to 'app.py') diff --git a/app.py b/app.py new file mode 100644 index 0000000..b52cd0b --- /dev/null +++ b/app.py @@ -0,0 +1,35 @@ +import configparser +import database +import flask + +app = flask.Flask(__name__) +CONFIG = configparser.ConfigParser() +CONFIG.read("edaweb.conf") + +def get_template_items(title, db): + return { + "links": db.get_header_links(), + "image": db.get_image("telegrampic"), + "title": title, + "articles": db.get_header_articles() + } + +@app.route("/") +def index(): + with database.Database() as db: + return flask.render_template( + "index.html", + **get_template_items("edaweb.co.uk", db) + ) + +@app.route("/discord") +def discord(): + with database.Database() as db: + return flask.render_template( + "discord.html", + **get_template_items("Discord", db), + discord = CONFIG["discord"]["username"] + ) + +if __name__ == "__main__": + app.run(host = "0.0.0.0", debug = True) -- cgit v1.2.3