|
|
@ -9,6 +9,9 @@ from flask import Flask, Response, render_template, request, send_from_directory |
|
|
|
from prefect.deployments import run_deployment |
|
|
|
|
|
|
|
PORT = 9021 |
|
|
|
PROTO = "https" |
|
|
|
BARE = True |
|
|
|
|
|
|
|
app = Flask(__name__) |
|
|
|
|
|
|
|
logging.basicConfig(level=logging.DEBUG) |
|
|
@ -22,20 +25,20 @@ def get_host(): |
|
|
|
host = os.environ.get("LIGHTNING_CLOUDSPACE_HOST") |
|
|
|
if host is None: |
|
|
|
default_host = os.environ.get("HOST_NAME", "0.0.0.0") |
|
|
|
return f"{default_host}:{PORT}" |
|
|
|
return f"{default_host}:{PORT}" if not BARE else f"{default_host}" |
|
|
|
else: |
|
|
|
return f"{PORT}-{host}" |
|
|
|
return f"{PORT}-{host}" if not BARE else f"{host}" |
|
|
|
|
|
|
|
|
|
|
|
@app.route("/iframe") |
|
|
|
@app.route("/iframe/") |
|
|
|
@app.route("/iframe/<path:subpath>") |
|
|
|
def home(subpath="images/animations/"): |
|
|
|
def home(subpath="images/animations/", proto=PROTO): |
|
|
|
host = get_host() |
|
|
|
initial_url = f"http://{host}/{subpath}" |
|
|
|
api_url = f"http://{host}/api" |
|
|
|
initial_url = f"{proto}://{host}/{subpath}" |
|
|
|
api_url = f"{proto}://{host}/api" |
|
|
|
return render_template( |
|
|
|
"index.html", initial_url=initial_url, host=f"http://{host}", api_url=api_url |
|
|
|
"index.html", initial_url=initial_url, host=f"{proto}://{host}", api_url=api_url |
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
@ -70,10 +73,10 @@ def custom_static(filename): |
|
|
|
|
|
|
|
@app.route("/", methods=["GET"]) |
|
|
|
@app.route("/<path:url>", methods=["GET"]) |
|
|
|
def proxy(url=""): |
|
|
|
def proxy(url="", proto=PROTO): |
|
|
|
original_base_url = "https://services.swpc.noaa.gov" |
|
|
|
host = get_host() |
|
|
|
proxy_base_url = f"http://{host}/" |
|
|
|
proxy_base_url = f"{proto}://{host}/" |
|
|
|
|
|
|
|
target_url = f"{original_base_url}/{url}" |
|
|
|
logging.debug(f"Fetching URL: {target_url}") |
|
|
|