Initial code
This commit is contained in:
parent
f628266c2a
commit
3519df4299
5 changed files with 114 additions and 0 deletions
25
http_test_server.py
Normal file
25
http_test_server.py
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
from http.server import BaseHTTPRequestHandler, HTTPServer
|
||||
|
||||
import os
|
||||
|
||||
PORT = int(os.getenv("PORT", "8000"))
|
||||
|
||||
class handler(BaseHTTPRequestHandler):
|
||||
def do_GET(self):
|
||||
self.send_response(200)
|
||||
self.send_header('Content-type','text/html')
|
||||
self.end_headers()
|
||||
|
||||
message = "Hello, World! Here is a GET response"
|
||||
self.wfile.write(bytes(message, "utf8"))
|
||||
def do_POST(self):
|
||||
self.send_response(200)
|
||||
self.send_header('Content-type','application/json')
|
||||
self.end_headers()
|
||||
|
||||
message = "{\"hello\": \"response\"}"
|
||||
self.wfile.write(bytes(message, "utf8"))
|
||||
|
||||
with HTTPServer(('', PORT), handler) as server:
|
||||
server.serve_forever()
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue