Mercurial > hg > index.fcgi > www > www-1
view cs/cs_flask_app.py @ 139:cdbeddce6b10
myrss2: FEEDS: Update new.google.com URLs
author | paulo |
---|---|
date | Tue, 02 May 2023 05:09:32 +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)