Mercurial > hg > index.fcgi > www > www-1
comparison cs/cs_flask_app.py @ 141:df18c9d8857c
myrss2: FEEDS: Add theconversation.com, remove Coding Horror
author | paulo |
---|---|
date | Sun, 06 Aug 2023 17:34:26 +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) |