Mercurial > hg > index.fcgi > www > www-1
view cs/cs_flask_app.py @ 140:ae6b4032a912
myrss2: FEEDS: Add jabberwocking.com, remove danielmiessler.com
author | paulo |
---|---|
date | Mon, 03 Jul 2023 04:40:23 +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)