Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

app.py 533 B

You have to be logged in to leave a comment. Sign In
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
  1. import yfinance as yf
  2. from flask import request, render_template, jsonify, Flask
  3. app = Flask(__name__, template_folder = 'templates')
  4. @app.route('/')
  5. def index():
  6. return render_template('Existing.html')
  7. @app.route('/get_stock_data', methods=['POST'])
  8. def get_stock_data():
  9. ticker = request.get_json()['ticker']
  10. data = yf.Ticker(ticker).history(period='1y')
  11. return jsonify({'currentPrice':data.iloc[-1].Close,
  12. 'openPrice':data.iloc[-1].Open})
  13. if __name__ == '__main__':
  14. app.run(debug=True)
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...