Last active
November 22, 2017 13:52
-
-
Save bjoern-r/7bbce17e493d1ce6dc371a4a8f6a3051 to your computer and use it in GitHub Desktop.
Host the openstack dashboard horizon using wsgiref.simple_server and werkzeug
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import logging | |
import os | |
import sys | |
from django.core.wsgi import get_wsgi_application | |
from django.conf import settings | |
from wsgiref.simple_server import make_server | |
from werkzeug.wsgi import SharedDataMiddleware,DispatcherMiddleware | |
from werkzeug.exceptions import NotFound | |
from werkzeug.utils import redirect | |
OLDPATH = '/usr/share/openstack-dashboard/openstack_dashboard/wsgi' | |
# Add this file path to sys.path in order to import settings | |
sys.path.insert(0, os.path.join(OLDPATH, '../..')) | |
os.environ['DJANGO_SETTINGS_MODULE'] = 'openstack_dashboard.settings' | |
sys.stdout = sys.stderr | |
DEBUG = False | |
DEBUG = True # bri | |
if __name__ == '__main__': | |
redirect_dashboard = redirect('/dashboard') | |
app_dashboard = SharedDataMiddleware(get_wsgi_application(), { | |
'/static': '/usr/share/openstack-dashboard/static' | |
}) | |
app = DispatcherMiddleware(redirect_dashboard, { | |
'/test': NotFound(), | |
'/dashboard': app_dashboard | |
}) | |
httpd = make_server('', 8000, app) | |
print("Serving on port 8000...") | |
httpd.serve_forever() | |
else: | |
application = get_wsgi_application() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment