-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'dev' of https://github.com/introlab/opentera-dashboards…
…-service into dev
- Loading branch information
Showing
3 changed files
with
28 additions
and
61 deletions.
There are no files selected for viewing
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
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,38 @@ | ||
from flask.views import MethodView | ||
from FlaskModule import flask_app | ||
import os | ||
|
||
from urllib.parse import quote | ||
|
||
from werkzeug.exceptions import NotFound | ||
from flask import render_template, request | ||
from flask.views import MethodView | ||
from flask_babel import gettext | ||
|
||
from FlaskModule import flask_app | ||
|
||
class Index(MethodView): | ||
# Decorators everywhere? | ||
# decorators = [auth.login_required] | ||
|
||
def __init__(self, *args, **kwargs): | ||
print('Index.__init__', args, kwargs) | ||
self.flaskModule = kwargs.get('flaskModule', None) | ||
|
||
def get(self): | ||
try: | ||
return flask_app.send_static_file('index.html') | ||
except NotFound: | ||
# If the file was not found, send the default index file | ||
backend_hostname = self.flaskModule.config.backend_config['hostname'] | ||
backend_port = self.flaskModule.config.backend_config['port'] | ||
|
||
# Look for variables set in NGINX reverse proxy... | ||
if 'X_EXTERNALSERVER' in request.headers: | ||
backend_hostname = request.headers['X_EXTERNALSERVER'] | ||
|
||
if 'X_EXTERNALPORT' in request.headers: | ||
backend_port = request.headers['X_EXTERNALPORT'] | ||
|
||
user_name = 'Anonymous' | ||
|
||
# Verify if static/DashboardsViewerApp.html exists | ||
# send default index.html if not | ||
if not os.path.exists('static/DashboardsViewerApp.html'): | ||
return flask_app.send_static_file('default_index.html') | ||
|
||
return render_template('dashboards.html', | ||
backend_hostname=quote(backend_hostname), | ||
backend_port=quote(backend_port), | ||
user_name=quote(user_name), | ||
user_token='') |