view 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
line source
1 import os
3 import flask
4 import google.cloud.storage
5 from html3.html3 import HTML
7 app = flask.Flask(__name__)
9 GCS_CLIENT = google.cloud.storage.Client()
10 GCS_BUCKET = GCS_CLIENT.get_bucket(os.environ.get("GCS_BUCKET"))
12 @app.route("/")
13 def index():
14 return flask.redirect(flask.url_for("file_serve", filename="index.html"))
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)
23 return flask.send_file(file_blob.open("rb"), download_name=filename)