forked from sloppycoder/bank-demo
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver27.py
More file actions
30 lines (25 loc) · 705 Bytes
/
server27.py
File metadata and controls
30 lines (25 loc) · 705 Bytes
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
import BaseHTTPServer
import SocketServer
import json
import time
HOST_NAME = '0.0.0.0'
PORT_NUMBER =8080
customer = json.dumps({
'customer_id':'10001000',
'name' : '10001000',
'login_name' : '10001000'
})
class MyHandler(BaseHTTPServer.BaseHTTPRequestHandler):
def do_GET(s):
s.send_response(200)
s.send_header('Content-type', 'application/json')
s.end_headers()
s.wfile.write(customer)
if __name__ == '__main__':
httpd = BaseHTTPServer.HTTPServer((HOST_NAME, PORT_NUMBER), MyHandler)
print(time.asctime(), "Server Starts - %s:%s" % (HOST_NAME, PORT_NUMBER))
try:
httpd.serve_forever()
except KeyboardInterrupt:
pass
httpd.server_close()