paulo@131: import os paulo@131: paulo@131: import flask paulo@131: import google.cloud.storage paulo@131: from html3.html3 import HTML paulo@131: paulo@131: app = flask.Flask(__name__) paulo@131: paulo@131: GCS_CLIENT = google.cloud.storage.Client() paulo@131: GCS_BUCKET = GCS_CLIENT.get_bucket(os.environ.get("GCS_BUCKET")) paulo@131: paulo@131: @app.route("/") paulo@131: def index(): paulo@131: return flask.redirect(flask.url_for("file_serve", filename="index.html")) paulo@131: paulo@131: paulo@131: @app.route("/") paulo@131: def file_serve(filename): paulo@131: file_blob = GCS_BUCKET.get_blob(f"cs/{filename}") paulo@131: if not file_blob: paulo@131: flask.abort(404) paulo@131: paulo@131: return flask.send_file(file_blob.open("rb"), download_name=filename)