-
Notifications
You must be signed in to change notification settings - Fork 44
/
app.py
78 lines (59 loc) · 2.09 KB
/
app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
"""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')