Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…-service into dev
  • Loading branch information
SBriere committed Apr 30, 2024
2 parents 5504f77 + 9706fea commit 35ea7ff
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 61 deletions.
3 changes: 0 additions & 3 deletions FlaskModule.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,9 +252,6 @@ def init_views(self):
from views.Index import Index
flask_app.add_url_rule('/', view_func=Index.as_view('index', *args, **kwargs))

from views.Dashboards import DashboardsIndex
flask_app.add_url_rule('/dashboards', view_func=DashboardsIndex.as_view('dashboards', *args, **kwargs))


@flask_app.errorhandler(404)
def page_not_found(e):
Expand Down
48 changes: 0 additions & 48 deletions views/Dashboards.py

This file was deleted.

38 changes: 28 additions & 10 deletions views/Index.py
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='')

0 comments on commit 35ea7ff

Please sign in to comment.