aboutsummaryrefslogtreecommitdiff
path: root/hex_zero.py
diff options
context:
space:
mode:
authorB Stack <bgstack15@gmail.com>2020-12-10 19:01:27 -0500
committerB Stack <bgstack15@gmail.com>2020-12-10 19:01:27 -0500
commitb24910be0f15e0268436111fc2c579c7d1685fa0 (patch)
treefac06b8f4e33fbf1e796789e2521a054c9ce2690 /hex_zero.py
parentimprove front page html (diff)
downloadhex-zero-b24910be0f15e0268436111fc2c579c7d1685fa0.tar.gz
hex-zero-b24910be0f15e0268436111fc2c579c7d1685fa0.tar.bz2
hex-zero-b24910be0f15e0268436111fc2c579c7d1685fa0.zip
gracefully handle when x_forwarded_for is null
Diffstat (limited to 'hex_zero.py')
-rwxr-xr-xhex_zero.py9
1 files changed, 6 insertions, 3 deletions
diff --git a/hex_zero.py b/hex_zero.py
index 81c8169..b534a51 100755
--- a/hex_zero.py
+++ b/hex_zero.py
@@ -382,9 +382,12 @@ def fhost():
out = None
if "file" in request.files:
- if app.config["USE_HTTP_X_FORWARDED_FOR"]:
- stored_ip_address = request.environ["HTTP_X_FORWARDED_FOR"]
- else:
+ try:
+ if app.config["USE_HTTP_X_FORWARDED_FOR"]:
+ stored_ip_address = request.environ["HTTP_X_FORWARDED_FOR"]
+ else:
+ stored_ip_address = request.remote_addr
+ except:
stored_ip_address = request.remote_addr
out = store_file(request.files["file"], stored_ip_address)
elif "url" in request.form:
bgstack15