aromidvar commited on
Commit
87760cd
·
verified ·
1 Parent(s): a31e2bc

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -42
app.py CHANGED
@@ -14,7 +14,7 @@ db = SQLAlchemy(app)
14
 
15
 
16
  # Set up logging
17
- logging.basicConfig(level=logging.DEBUG)
18
  logger = logging.getLogger(__name__)
19
 
20
  # Database model for storing economic indicators
@@ -43,6 +43,7 @@ def create_dummy_data():
43
  @app.route('/search', methods=['POST'])
44
  def search():
45
  """Search for economic indicators."""
 
46
  try:
47
  query = request.json['query']
48
  results = EconomicData.query.filter(EconomicData.indicator.ilike(f'%{query}%')).all()
@@ -92,44 +93,5 @@ def gradio_ui():
92
  response = requests.post(f'http://localhost:5000/search', json={'query': query})
93
  return response.json()
94
 
95
- def call_predict(num_predictions):
96
- response = requests.post(f'http://localhost:5000/predict', json={'num_predictions': num_predictions})
97
- return response.json()
98
-
99
- def call_economic_data():
100
- response = requests.get('http://localhost:5000/economic_data')
101
- return response.json()
102
-
103
- with gr.Blocks() as demo:
104
- gr.Markdown("# Economic DataHub")
105
- gr.Markdown("Welcome to the interactive Economic DataHub. Explore economic indicators, make predictions, and access detailed economic data.")
106
-
107
- with gr.Tab("Search Economic Indicators"):
108
- search_input = gr.Textbox(label="Search for Economic Terms:", placeholder="Enter an economic term...")
109
- search_button = gr.Button("Search")
110
- search_output = gr.Textbox(label="Results", interactive=False)
111
-
112
- search_button.click(call_search, inputs=search_input, outputs=search_output)
113
-
114
- with gr.Tab("Time Series Prediction"):
115
- num_predictions = gr.Slider(minimum=1, maximum=30, step=1, label="Number of Days to Predict")
116
- predict_button = gr.Button("Predict")
117
- prediction_output = gr.Textbox(label="Predictions", interactive=False)
118
-
119
- predict_button.click(call_predict, inputs=num_predictions, outputs=prediction_output)
120
-
121
- with gr.Tab("Retrieve Economic Data"):
122
- retrieve_button = gr.Button("Get Economic Data")
123
- data_output = gr.Textbox(label="Economic Data", interactive=False)
124
-
125
- retrieve_button.click(call_economic_data, outputs=data_output)
126
-
127
- demo.launch(server_name="0.0.0.0", server_port=7860, share=True)
128
-
129
- # Initialize database and run the app
130
- if __name__ == '__main__':
131
- initialize_db() # Initialize the database
132
- # Start the Flask app in a separate thread
133
- threading.Thread(target=app.run, kwargs={'debug': True}).start()
134
- # Start the Gradio UI
135
- gradio_ui()
 
14
 
15
 
16
  # Set up logging
17
+ logging.basicConfig(level=logging.DEBUG, format='%(asctime)s - %(levelname)s - %(message)s')
18
  logger = logging.getLogger(__name__)
19
 
20
  # Database model for storing economic indicators
 
43
  @app.route('/search', methods=['POST'])
44
  def search():
45
  """Search for economic indicators."""
46
+ logger.debug("Search endpoint hit.") # Log when the endpoint is accessed
47
  try:
48
  query = request.json['query']
49
  results = EconomicData.query.filter(EconomicData.indicator.ilike(f'%{query}%')).all()
 
93
  response = requests.post(f'http://localhost:5000/search', json={'query': query})
94
  return response.json()
95
 
96
+ def call
97
+