repl.it
@PYer/

Stock Simulation

Python

No description

fork
loading
Files
  • main.py
  • Packager files
  • poetry.lock
  • pyproject.toml
  • requirements.txt
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import flask, requests

app = flask.Flask('app')
watchlist = ['^DJI', '^GSPC']

@app.route('/')
def home():
  return 'Hello World'

@app.route('/play', methods=['GET'])
def play():
  api = 'https://Stock-Value.pyer.repl.co/json?sym='
  newsym = flask.request.args.get('sym')
  if newsym: watchlist.append(newsym)
  shares = {}
  listhtml = ''
  for sym in watchlist:
    data = requests.get(api + sym).text.split()
    listhtml += '<span>' + sym + '</span><br>' + data[0] + '<br><br>'
  return '<h1>Stock Simulation</h1>' + listhtml + '<form>Add To Watchlist<br><input name="sym" placeholder="SYMBOL"></input></form><a href="https://stock-simulation.pyer.repl.co/play">Reload Watchlist</a>'

app.run(host='0.0.0.0', port=6506)
Fetching token
?