sikeaditya commited on
Commit
d097af3
·
verified ·
1 Parent(s): 6804d6b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -2
app.py CHANGED
@@ -509,6 +509,19 @@ def get_commodities():
509
  commodities = sorted(df['commodity'].dropna().unique())
510
  return jsonify(commodities)
511
 
 
 
 
 
 
 
 
 
 
 
 
 
 
512
  if __name__ == '__main__':
513
- app.run(debug=True, host='0.0.0.0', port=7860)
514
- pio.templates.default = "plotly_white"
 
509
  commodities = sorted(df['commodity'].dropna().unique())
510
  return jsonify(commodities)
511
 
512
+ @app.route('/')
513
+ def index():
514
+ try:
515
+ initial_data = fetch_market_data()
516
+ states = sorted(initial_data['state'].dropna().unique()) if not initial_data.empty else []
517
+ except Exception as e:
518
+ print(f"Error fetching initial data: {str(e)}")
519
+ states = []
520
+
521
+ return render_template('index.html',
522
+ states=states,
523
+ today=datetime.today().strftime('%Y-%m-%d'))
524
+
525
  if __name__ == '__main__':
526
+ pio.templates.default = "plotly_white"
527
+ app.run(debug=True, host='0.0.0.0', port=7860)