Skip to content

Commit

Permalink
add wsgi.py file
Browse files Browse the repository at this point in the history
  • Loading branch information
dtkav committed Jan 8, 2019
1 parent df2d99e commit 566b4ec
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions connexion/wsgi.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
from flask import Flask, flash, render_template, redirect, url_for, session, request, send_from_directory, abort
from flask import Response, Blueprint
from werkzeug.serving import run_simple
from werkzeug.wsgi import DispatcherMiddleware
import datetime

class ReverseProxied(object):

def __init__(self, app, script_name=None, scheme=None, server=None):
self.app = app
self.script_name = script_name
self.scheme = scheme
self.server = server
print("initted!")

def __call__(self, environ, start_response):
script_name = environ.get('HTTP_X_SCRIPT_NAME', '') or self.script_name
if script_name:
environ['SCRIPT_NAME'] = script_name
path_info = environ['PATH_INFO']
if path_info.startswith(script_name):
environ['PATH_INFO_OLD'] = path_info
environ['PATH_INFO'] = path_info[len(script_name):]
scheme = environ.get('HTTP_X_SCHEME', '') or self.scheme
if scheme:
environ['wsgi.url_scheme'] = scheme
server = environ.get('HTTP_X_FORWARDED_SERVER', '') or self.server
if server:
environ['HTTP_HOST'] = server
return self.app(environ, start_response)

0 comments on commit 566b4ec

Please sign in to comment.