-
Notifications
You must be signed in to change notification settings - Fork 11
/
app.py
54 lines (40 loc) · 1.13 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
import os
import pickle
import uuid
import dash_bootstrap_components as dbc
import dash_mantine_components as dmc
import openai
from dash import Dash, Input, Output, State, callback, page_container
from flask import request
import utils
from constants import redis_instance
openai.api_key = os.getenv("OPEN_AI_KEY")
app = Dash(
__name__,
suppress_callback_exceptions=True,
external_scripts=["https://cdn.plot.ly/plotly-2.18.2.min.js"],
external_stylesheets=[dbc.themes.BOOTSTRAP],
title="AI Data Insights",
use_pages=True,
)
server = app.server
def layout():
return dmc.MantineProvider(
[
utils.jumbotron(),
page_container,
],
)
app.layout = layout
@callback(
Output("save-clip", "content"),
Input("save-clip", "n_clicks"),
State("current-charts", "children"),
prevent_initial_call=True,
)
def copy_link_to_view(n, current):
figure_id = str(uuid.uuid4())
redis_instance.set(figure_id, pickle.dumps(current))
return request.host_url[:-1] + app.get_relative_path(f"/view?layout={figure_id}")
if __name__ == "__main__":
app.run(debug=True)