Mercurial > hg > index.fcgi > www > www-1
comparison cs/cs_flask_app.py @ 142:2ed8cf5f36bf
myrss2: fix handling of null feed title or links; miscellaneous URL updates
author | paulo |
---|---|
date | Mon, 18 Dec 2023 20:10:27 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:8f2ecf8c00a5 |
---|---|
1 import os | |
2 | |
3 import flask | |
4 import google.cloud.storage | |
5 from html3.html3 import HTML | |
6 | |
7 app = flask.Flask(__name__) | |
8 | |
9 GCS_CLIENT = google.cloud.storage.Client() | |
10 GCS_BUCKET = GCS_CLIENT.get_bucket(os.environ.get("GCS_BUCKET")) | |
11 | |
12 @app.route("/") | |
13 def index(): | |
14 return flask.redirect(flask.url_for("file_serve", filename="index.html")) | |
15 | |
16 | |
17 @app.route("/<filename>") | |
18 def file_serve(filename): | |
19 file_blob = GCS_BUCKET.get_blob(f"cs/{filename}") | |
20 if not file_blob: | |
21 flask.abort(404) | |
22 | |
23 return flask.send_file(file_blob.open("rb"), download_name=filename) |