-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-program.py
More file actions
66 lines (59 loc) · 1.5 KB
/
Copy pathtest-program.py
File metadata and controls
66 lines (59 loc) · 1.5 KB
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
from flask import Flask
import requests
testapp = Flask(__name__)
# Routes
@testapp.route('/stocksort-test')
def sortStocksTest():
# Define body of request
stockSortRequestBody = {
"sortBy": "price",
"sortOrder": "asc",
"stocks": [
{
"ticker": "AAPL",
"price": 235.86,
"changePercent": -0.26,
"52WLow": 164.08,
"52WHigh": 237.49,
"recommendation": "buy"
},
{
"ticker": "TSLA",
"price": 217.97,
"changePercent": -0.4,
"52WLow": 138.8,
"52WHigh": 271.0,
"recommendation": "hold"
},
{
"ticker": "PLTR",
"price": 42.94,
"changePercent": 0.56,
"52WLow": 14.48,
"52WHigh": 44.39,
"recommendation": "hold"
},
{
"ticker": "GOOG",
"price": 166.82,
"changePercent": 0.62,
"52WLow": 121.46,
"52WHigh": 193.31,
"recommendation": "buy"
}
]
}
# Make call to stock sorting service
stockSortRequest = requests.post("https://stocksortingservice.onrender.com/stocksort", json=stockSortRequestBody)
# Receive response from stock sorting service
if stockSortRequest.status_code == 200:
# Successful call - store response and process accordingly
stockSortResponse = stockSortRequest.json()
return stockSortResponse
else:
# Add error handling here
return
# Listener
if __name__ == "__main__":
#Start the app on port 7790
testapp.run(port=7790, debug=True)