From c9e925081564668beaa506e3cb4f7463bd4b6068 Mon Sep 17 00:00:00 2001 From: iou1name Date: Tue, 31 Jul 2018 17:12:15 -0400 Subject: [PATCH] I learned about SCRIPT_NAME --- README.md | 2 +- anonkun.py | 36 ------------------------------------ templates/quest.html | 11 +++-------- 3 files changed, 4 insertions(+), 45 deletions(-) diff --git a/README.md b/README.md index 75fc60d..3174c44 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ mysql> \q 2. Walk the dinosaur ## Usage -`gunicorn -b localhost:5050 --worker-class eventlet anonkun:app` +`gunicorn -b localhost:5050 -e SCRIPT_NAME=/anonkun --worker-class eventlet anonkun:app` ## Todo Rename this project to something that doesn't mean "shit" in weebspeak. diff --git a/anonkun.py b/anonkun.py index acfb8cc..4e9c99b 100644 --- a/anonkun.py +++ b/anonkun.py @@ -16,43 +16,7 @@ import database as db from views import views from events import socketio -class ReverseProxied(object): - """ - Wrap the application in this middleware and configure the - front-end server to add these headers, to let you quietly bind - this to a URL other than / and to an HTTP scheme that is - different than what is used locally. - - In nginx: - location /myprefix { - proxy_pass http://192.168.0.1:5001; - proxy_set_header Host $host; - proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; - proxy_set_header X-Scheme $scheme; - proxy_set_header X-Script-Name /myprefix; - } - - :param app: the WSGI application - """ - def __init__(self, app): - self.app = app - - def __call__(self, environ, start_response): - script_name = environ.get('HTTP_X_SCRIPT_NAME', '') - if script_name: - environ['SCRIPT_NAME'] = script_name - path_info = environ['PATH_INFO'] - if path_info.startswith(script_name): - environ['PATH_INFO'] = path_info[len(script_name):] - - scheme = environ.get('HTTP_X_SCHEME', '') - if scheme: - environ['wsgi.url_scheme'] = scheme - return self.app(environ, start_response) - - app = Flask(__name__) -app.wsgi_app = ReverseProxied(app.wsgi_app) app.wsgi_app = ProxyFix(app.wsgi_app) app.register_blueprint(views) app.config['MAX_CONTENT_LENGTH'] = 16 * 1024 * 1024 diff --git a/templates/quest.html b/templates/quest.html index 169388c..2436810 100644 --- a/templates/quest.html +++ b/templates/quest.html @@ -40,14 +40,9 @@ {% if quest_post[3] == "text" %}
Edit - {% elif quest_post[3] == "dice" or quest_post[3] == "poll" and quest_post == quest_posts|last %} - {% if quest_post[0] == open_post_id %} -
Close - - {% else %} -
- Open - {% endif %} + {% elif (quest_post[3] == "dice" or quest_post[3] == "poll") and quest_post == quest_posts|last %} +
+ {% endif %} {% endif %}