-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstock_check.py
More file actions
28 lines (21 loc) · 883 Bytes
/
stock_check.py
File metadata and controls
28 lines (21 loc) · 883 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
from flask import Flask, render_template, redirect, url_for, request
import requests
app = Flask(__name__)
@app.route('/stock',methods=['GET'])
def stock():
return render_template('stock.html')
@app.route('/result',methods=['GET', 'POST'])
def result():
error = None
if request.method == 'POST':
tickerCode = request.form['stockSymbol']
api_key = request.form['APIKey']
url = "https://www.alphavantage.co/query"
querystring = {"function":"TIME_SERIES_INTRADAY","symbol":tickerCode,"interval":"5min","apikey":api_key}
payload = ""
headers = {
'Cache-Control': "no-cache",
'Postman-Token': "c50d8ad2-56d2-4114-9244-6dc770d9e5c0,b7b7eaec-bdc1-453f-bd6b-96fa8ce1e741",
}
response = requests.request("GET", url, headers=headers, params=querystring)
return response.text