-
Notifications
You must be signed in to change notification settings - Fork 0
/
0001-Create-Patch-File.patch
73 lines (64 loc) · 2.23 KB
/
0001-Create-Patch-File.patch
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
67
68
69
70
71
72
From 82abf92e8788d15c78111b847a36c55f0faac62e Mon Sep 17 00:00:00 2001
From: Minji Kim <[email protected]>
Date: Mon, 12 Oct 2020 00:51:34 -0500
Subject: [PATCH] Create Patch File
---
client3.py | 10 ++++++----
server3.py | 4 ++--
2 files changed, 8 insertions(+), 6 deletions(-)
diff --git a/client3.py b/client3.py
index f1771c3..b2576fd 100644
--- a/client3.py
+++ b/client3.py
@@ -24,7 +24,7 @@ import json
import random
# Server API URLs
-QUERY = "http://localhost:8080/query?id={}"
+QUERY = "http://localhost:8085/query?id={}"
# 500 server request
N = 500
@@ -35,14 +35,16 @@ def getDataPoint(quote):
stock = quote['stock']
bid_price = float(quote['top_bid']['price'])
ask_price = float(quote['top_ask']['price'])
- price = bid_price
+ price = (bid_price + ask_price)/2
return stock, bid_price, ask_price, price
def getRatio(price_a, price_b):
""" Get ratio of price_a and price_b """
""" ------------- Update this function ------------- """
""" Also create some unit tests for this function in client_test.py """
- return 1
+ if (price_b == 0):
+ return
+ return price_a/price_b
# Main
if __name__ == "__main__":
@@ -56,4 +58,4 @@ if __name__ == "__main__":
stock, bid_price, ask_price, price = getDataPoint(quote)
print ("Quoted %s at (bid:%s, ask:%s, price:%s)" % (stock, bid_price, ask_price, price))
- print ("Ratio %s" % getRatio(price, price))
+ print ("Ratio %s" % getRatio(price['ABC'], price['DEF']))
diff --git a/server3.py b/server3.py
index 2de4e28..1d59866 100644
--- a/server3.py
+++ b/server3.py
@@ -202,7 +202,7 @@ def get(req_handler, routes):
req_handler.wfile.write(bytes(data, encoding = 'utf-8'))
return
-def run(routes, host = '0.0.0.0', port = 8080):
+def run(routes, host = '0.0.0.0', port = 8085):
""" Runs a class as a server whose methods have been decorated with
@route.
"""
@@ -215,7 +215,7 @@ def run(routes, host = '0.0.0.0', port = 8080):
thread = threading.Thread(target = server.serve_forever)
thread.daemon = True
thread.start()
- print ('HTTP server started on port 8080')
+ print ('HTTP server started on port 8085')
while True:
from time import sleep
sleep(1)
--
2.28.0.windows.1