Files
wehub-resource-sync f0dfbfc3d7
RequirementsTest / build (windows-latest, 3.9) (push) Has been cancelled
RequirementsTest / build (macos-latest, 3.9) (push) Has been cancelled
RequirementsTest / build (ubuntu-latest, 3.9) (push) Has been cancelled
CodeQL / Analyze (javascript) (push) Has been cancelled
CodeQL / Analyze (python) (push) Has been cancelled
Pylint / build (3.9) (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 13:18:32 +08:00

79 lines
2.1 KiB
Python

"""App
This script allows connects and interacts with Flask and Dash components.
This script requires that `flask` and 'dash' be installed within the Python
environment you are running this script in.
This file can also be imported as a module and contains the following
functions:
* dataframe_return - list of Dataframes from dataframe_visualizer
* root - returns the index page
"""
from flask import Flask, render_template, request
import dash_bootstrap_components as dbc
import dash
from dash import html
from libs.dataframe_visualizer import dataframe_visualizer
app = Flask(__name__)
app.config['MAX_CONTENT_LENGTH'] = 1024 * 1024
app = Flask(__name__)
app.config['SECRET_KEY'] = 'secret!'
app.config['DEBUG'] = True
DASH_APP = dash.Dash(
routes_pathname_prefix='/visualizer/',
server=app,
external_scripts=[
'https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.52.2/codemirror.min.js',
'custom-script.js'
],
external_stylesheets=[
'https://fonts.googleapis.com/css?family=Lato',
'https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css',
'https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.52.2/theme/monokai.min.css',
'https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.52.2/codemirror.min.css',
'styles.css',
dbc.themes.BOOTSTRAP
],
name='CSV Visualizer',
title='CSV Visualizer'
)
DASH_APP.config.suppress_callback_exceptions = True
DASH_APP.validation_layout = html.Div()
DASH_APP.layout = html.Div()
@app.route('/DataVisualizer', methods=['POST', 'GET'])
def dataframe_return():
"""returns list of Dataframes from dataframe_visualizer
Returns:
string: list of datafrmaes
"""
# pylint: disable=W0603
global DASH_APP
list_dataframe, DASH_APP = dataframe_visualizer(request.form, DASH_APP)
return str(list_dataframe)
@app.route('/', methods=['POST', 'GET'])
def root():
"""renders undex.html
Returns:
_render: rendered html
"""
return render_template('index.html')
if __name__ == '__main__':
app.run(host='0.0.0.0')