-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
29 lines (22 loc) · 844 Bytes
/
main.py
File metadata and controls
29 lines (22 loc) · 844 Bytes
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
import pandas as pd
from flask import Flask, jsonify, request, send_file
import io
# load csv
df = pd.read_csv('constituents-financials_csv.csv')
app = Flask(__name__)
@app.route('/Sector')
def unique_sectors():
unique_sector = df['Sector'].unique().tolist()
return jsonify({'sectors': unique_sector})
@app.route('/EBITDA')
def ebitda():
sector = request.args.get('Sector') # Get the 'Sector' parameter from the URL
ebitda_values = df[df['Sector'] == sector]['EBITDA'].tolist()
return jsonify(ebitda_values) # Return the list of EBITDAs as JSON
@app.route('/download_csv', methods=['GET'])
def download_csv():
return send_file('constituents-financials_csv.csv')
def main():
app.run(debug=True, port=5000) # Change port to 5000
if __name__ == '__main__':
main() # Call the main function to run the app