mirror of
https://github.com/swizzin/swizzin_dashboard.git
synced 2024-09-20 14:56:08 +08:00
fc9f1d6035
* Prefix attempt * Attempt to fix websocket * Move certain functions to macros * Fix test variable * Attempt to fix forms login * Fix static url * Fix typo * Remove more static definitions * Fix referral * Fix syntax * append slash if needed * Refine login urlbase logic * Fix syntax * fix redirect * Fix brackets * Fix fix brackets
13 lines
558 B
Python
13 lines
558 B
Python
class PrefixMiddleware(object):
|
|
def __init__(self, app, prefix=''):
|
|
self.app = app
|
|
self.prefix = prefix
|
|
|
|
def __call__(self, environ, start_response):
|
|
if environ['PATH_INFO'].startswith(self.prefix):
|
|
environ['PATH_INFO'] = environ['PATH_INFO'][len(self.prefix):]
|
|
environ['SCRIPT_NAME'] = self.prefix
|
|
return self.app(environ, start_response)
|
|
else:
|
|
start_response('404', [('Content-Type', 'text/plain')])
|
|
return ["This url does not belong to the app.".encode()] |