diff options
author | B. Stack <bgstack15@gmail.com> | 2022-03-17 17:33:42 -0400 |
---|---|---|
committer | B. Stack <bgstack15@gmail.com> | 2022-03-17 17:33:42 -0400 |
commit | 8785f50d470dc6f23c5728447c8f3d5c04ca84f2 (patch) | |
tree | eb2aca6ebfa73307fc7b988b4a435d10260337a2 | |
parent | Merge branch 'dev' into 'master' (diff) | |
download | stackbin-8785f50d470dc6f23c5728447c8f3d5c04ca84f2.tar.gz stackbin-8785f50d470dc6f23c5728447c8f3d5c04ca84f2.tar.bz2 stackbin-8785f50d470dc6f23c5728447c8f3d5c04ca84f2.zip |
include SET_URL conf setting for self-setting
-rw-r--r-- | stackbin.conf.dev | 5 | ||||
-rw-r--r-- | stackbin.conf.example | 5 | ||||
-rw-r--r-- | stackbin.py | 7 |
3 files changed, 16 insertions, 1 deletions
diff --git a/stackbin.conf.dev b/stackbin.conf.dev index e2fa21f..751114b 100644 --- a/stackbin.conf.dev +++ b/stackbin.conf.dev @@ -26,3 +26,8 @@ ADMIN_PASSWORD = 'fluffycat10' # Because the app generates the url entirely from scratch for a curl POST, the protocol can get lost, so you can force https if you define this variable. CURL_RESPONSE_PROTOCOL = "https" + +# If this is set, at the first request, the web app will visit this url to set its own prefix. +# This is designed so that you can use your own final URL for the /set endpoint in a config file, +# so the app will auto-configure itself. +SET_URL = "https://bgstack15.ddns.net/stackbin/set" diff --git a/stackbin.conf.example b/stackbin.conf.example index 518af7c..6400ff1 100644 --- a/stackbin.conf.example +++ b/stackbin.conf.example @@ -26,3 +26,8 @@ ADMIN_PASSWORD = 'fluffycat10' # Because the app generates the url entirely from scratch for a curl POST, the protocol can get lost, so you can force https if you define this variable. CURL_RESPONSE_PROTOCOL = "https" + +# If this is set, at the first request, the web app will visit this url to set its own prefix. +# This is designed so that you can use your own final URL for the /set endpoint in a config file, +# so the app will auto-configure itself. +SET_URL = "https://example.com/stackbin/set" diff --git a/stackbin.py b/stackbin.py index b245206..321cd91 100644 --- a/stackbin.py +++ b/stackbin.py @@ -98,6 +98,11 @@ def refresh_string(delay,url): """ return f'<meta http-equiv="Refresh" content="{delay}; url={url}">' +@app.before_first_request +def visit_set(): + if 'SET_URL' in app.config and '/set' in app.config['SET_URL']: + os.system(f"curl {app.config['SET_URL']} 1>/dev/null 2>&1 &") + @app.before_request def check_user_status(): g.user = None @@ -381,7 +386,7 @@ def favicon(): @app.route('/set') def get_proxied_path(): prefix = "/" - print(f"DEBUG: request.environ: {request.environ}") + #print(f"DEBUG: request.environ: {request.environ}") if 'HTTP_X_FORWARDED_PREFIX' in request.environ: hl = len(dict(request.headers)["X-Forwarded-Host"].split(", ")) pl = len(dict(request.headers)["X-Forwarded-Prefix"].split(", ")) |