Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from flask import Flask, render_template
- import requests
- app = Flask(__name__)
- API_URL = "https://financialmodelingprep.com/api/v3/stock/real-time-price/{TICKER}"
- @app.route('/<ticker>')
- def ticker_show(ticker):
- price = get_price(ticker=ticker)
- return render_template("stock_quote.html", ticker=ticker.upper(),stock_price=price)
- def get_price(ticker):
- data = requests.get(API_URL.format(ticker=ticker.upper()),
- params={"apikey": "a11094f84f3ad7ba97ffb1ff"}).json()
- return data["price"]
- @app.route("/")
- def index():
- return render_template("index.html")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement