-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathmain.py
More file actions
39 lines (25 loc) · 968 Bytes
/
main.py
File metadata and controls
39 lines (25 loc) · 968 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
30
31
32
33
34
35
36
37
38
39
import requests
from flask import Flask, request, send_from_directory
# Replace "YOUR_API_KEY_HERE" with your actual API key.
API_KEY = "YOUR_API_KEY_HERE"
BASE_URL = "https://www.alphavantage.co/query"
app = Flask(__name__)
@app.route("/")
def index():
return "Hello world! Your web application is working!"
@app.route('/stock', methods=['GET'])
def get_stock_data():
symbol = request.args.get('symbol')
params = {"function": "GLOBAL_QUOTE", "symbol": symbol, "apikey": API_KEY}
response = requests.get(BASE_URL, params=params)
return response.json()
@app.route('/.well-known/ai-plugin.json')
def serve_ai_plugin():
return send_from_directory('.',
'ai-plugin.json',
mimetype='application/json')
@app.route('/openapi.yaml')
def serve_openapi_yaml():
return send_from_directory('.', 'openapi.yaml', mimetype='text/yaml')
if __name__ == "__main__":
app.run(host='0.0.0.0', port=81)