diff options
Diffstat (limited to 'stackbin.py')
-rwxr-xr-x | stackbin.py | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/stackbin.py b/stackbin.py index bcfd3d5..e8948fd 100755 --- a/stackbin.py +++ b/stackbin.py @@ -5,6 +5,7 @@ from datetime import datetime, timedelta from itsdangerous import Signer from flask import (Flask, request, url_for, redirect, g, render_template, session, abort) from flask_sqlalchemy import SQLAlchemy +from werkzeug.middleware.proxy_fix import ProxyFix from pytimeparse.timeparse import timeparse # python3-pytimeparse # uwsgidecorators load will fail when using initdb.py but is also not necessary try: @@ -283,5 +284,13 @@ def favicon(): except: abort(404) +@app.route('/set') +def get_proxied_path(): + if 'HTTP_X_FORWARDED_PREFIX' in request.environ: + pl = len(dict(request.headers)["X-Forwarded-Host"].split(", ")) + #prefix = request.environ['HTTP_X_FORWARDED_PREFIX'] + app.wsgi_app = ProxyFix(app.wsgi_app,x_for=pl,x_host=pl,x_port=pl,x_prefix=pl,x_proto=pl) + return redirect(url_for('new_paste')) + if __name__ == "__main__": app.run() |