bluenevus commited on
Commit
6013c50
·
verified ·
1 Parent(s): a1eaab5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -8
app.py CHANGED
@@ -9,7 +9,7 @@ import os
9
  from pywebio import start_server
10
  from pywebio.input import file_upload, input
11
  from pywebio.output import put_text, put_image, put_row, put_column, use_scope, put_buttons
12
- from pywebio.session import set_env
13
  import base64
14
  import threading
15
 
@@ -124,24 +124,25 @@ def process_file(file, instructions):
124
  return [error_image] * 3
125
 
126
  def data_analysis_dashboard():
 
127
  put_text("# Data Analysis Dashboard")
128
 
129
  with use_scope('form'):
130
  put_row([
131
  put_column([
132
- put_text(file_upload("Upload Dataset", accept=[".csv", ".xlsx"], name="file")),
133
- put_text(input("Analysis Instructions", type="text", placeholder="Describe the analysis you want...", name="instructions")),
134
  put_buttons(['Generate Insights'], onclick=[lambda: generate_insights()])
135
  ])
136
  ])
137
 
138
  with use_scope('output'):
139
  for i in range(3):
140
- use_scope(f'visualization_{i+1}')
141
-
142
  def generate_insights():
143
- file = input('file')
144
- instructions = input('instructions')
145
 
146
  if not file or not instructions:
147
  put_text("Please upload a file and provide instructions.")
@@ -155,7 +156,7 @@ def generate_insights():
155
  img_str = base64.b64encode(buffered.getvalue()).decode()
156
  with use_scope(f'visualization_{i+1}', clear=True):
157
  put_image(img_str, width='100%')
158
-
159
  def main():
160
  data_analysis_dashboard()
161
 
 
9
  from pywebio import start_server
10
  from pywebio.input import file_upload, input
11
  from pywebio.output import put_text, put_image, put_row, put_column, use_scope, put_buttons
12
+ from pywebio.session import run_js, set_env
13
  import base64
14
  import threading
15
 
 
124
  return [error_image] * 3
125
 
126
  def data_analysis_dashboard():
127
+ set_env(title="Data Analysis Dashboard")
128
  put_text("# Data Analysis Dashboard")
129
 
130
  with use_scope('form'):
131
  put_row([
132
  put_column([
133
+ file_upload("Upload Dataset", accept=[".csv", ".xlsx"], name="file"),
134
+ input("Analysis Instructions", type="text", placeholder="Describe the analysis you want...", name="instructions"),
135
  put_buttons(['Generate Insights'], onclick=[lambda: generate_insights()])
136
  ])
137
  ])
138
 
139
  with use_scope('output'):
140
  for i in range(3):
141
+ put_scope(f'visualization_{i+1}')
142
+
143
  def generate_insights():
144
+ file = file_upload.files.get('file')
145
+ instructions = input.inputs.get('instructions')
146
 
147
  if not file or not instructions:
148
  put_text("Please upload a file and provide instructions.")
 
156
  img_str = base64.b64encode(buffered.getvalue()).decode()
157
  with use_scope(f'visualization_{i+1}', clear=True):
158
  put_image(img_str, width='100%')
159
+
160
  def main():
161
  data_analysis_dashboard()
162