aboutsummaryrefslogtreecommitdiffstats
path: root/edaweb/app.py
diff options
context:
space:
mode:
Diffstat (limited to 'edaweb/app.py')
-rw-r--r--edaweb/app.py60
1 files changed, 38 insertions, 22 deletions
diff --git a/edaweb/app.py b/edaweb/app.py
index 6902fe4..0d4458a 100644
--- a/edaweb/app.py
+++ b/edaweb/app.py
@@ -17,7 +17,7 @@ import io
app = flask.Flask(__name__)
CONFIG = configparser.ConfigParser(interpolation = None)
-CONFIG.read("edaweb.conf")
+CONFIG.read(os.path.join(os.path.dirname(__file__), "..", "edaweb.conf"))
shown_images = set()
shown_sidebar_images = set()
@@ -68,7 +68,7 @@ def index():
return flask.render_template(
"index.html.j2",
**get_template_items("eden's site :3", db),
- days_till_ffs = datetime.datetime(2025, 11, 8) - datetime.datetime.now(),
+ days_since_ffs = datetime.datetime.now() - datetime.datetime(2025, 11, 8),
markdown = parser.parse_text(f.read())[0],
featured_thoughts = db.get_featured_thoughts(),
commits = services.get_recent_commits(db)[:15],
@@ -79,6 +79,10 @@ def index():
def robots():
return flask.send_from_directory("static", "robots.txt")
+@app.route("/cow.txt")
+def moo():
+ return flask.send_from_directory("static", "cow.txt")
+
@app.route("/services")
def serve_services():
with database.Database() as db:
@@ -214,26 +218,26 @@ def get_iso_cd():
id_ = id_
)
-@app.route("/random")
-def serve_random():
- try:
- tags = flask.request.args['tags'].split(" ")
- except KeyError:
- flask.abort(400)
-
- sbi = services.get_random_image(tags)
- req = urllib.request.Request(sbi.imurl)
- mediaContent = urllib.request.urlopen(req).read()
- with open(os.path.join("static", "images", "random.jpg"), "wb") as f:
- f.write(mediaContent)
-
- with database.Database() as db:
- return flask.render_template(
- "random.html.j2",
- **get_template_items("random image", db),
- sbi = sbi,
- localimg = "/img/random.jpg?seed=%i" % random.randint(0, 9999)
- )
+#@app.route("/random")
+#def serve_random():
+# try:
+# tags = flask.request.args['tags'].split(" ")
+# except KeyError:
+# flask.abort(400)
+#
+# sbi = services.get_random_image(tags)
+# req = urllib.request.Request(sbi.imurl)
+# mediaContent = urllib.request.urlopen(req).read()
+# with open(os.path.join(os.path.dirname(__file__), "static", "images", "random.jpg"), "wb") as f:
+# f.write(mediaContent)
+#
+# with database.Database() as db:
+# return flask.render_template(
+# "random.html.j2",
+# **get_template_items("random image", db),
+# sbi = sbi,
+# localimg = "/img/random.jpg?seed=%i" % random.randint(0, 9999)
+# )
@app.route("/questions")
def serve_questions():
@@ -244,6 +248,18 @@ def serve_questions():
qnas_link = CONFIG.get("qnas", "url"),
qnas = db.get_qnas()
)
+
+@app.route("/question")
+def serve_question():
+ with database.Database() as db:
+ question_id = flask.request.args.get("id", type=int)
+ qna = db.get_qna(question_id)
+ return flask.render_template(
+ "question.html.j2",
+ **get_template_items("question from %s" % qna["qna"][2], db),
+ qnas_link = CONFIG.get("qnas", "url"),
+ qna = qna
+ )
if __name__ == "__main__":
try: