Add sample webserver
This commit is contained in:
parent
b95424a0f3
commit
070a7579ed
1 changed files with 30 additions and 0 deletions
30
web-to-db.py
Normal file
30
web-to-db.py
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
|
|
||||||
|
from http.server import BaseHTTPRequestHandler, HTTPServer
|
||||||
|
|
||||||
|
# HTTPRequestHandler class
|
||||||
|
class testHTTPServer_RequestHandler(BaseHTTPRequestHandler):
|
||||||
|
# GET
|
||||||
|
def do_GET(self):
|
||||||
|
# Send response status code
|
||||||
|
self.send_response(200)
|
||||||
|
|
||||||
|
# Send headers
|
||||||
|
self.send_header('Content-type','text/html')
|
||||||
|
self.end_headers()
|
||||||
|
|
||||||
|
# Send message back to client
|
||||||
|
message = "Hello world!"
|
||||||
|
# Write content as utf-8 data
|
||||||
|
self.wfile.write(bytes(message, "utf8"))
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
server_address = ('0.0.0.0', 8000)
|
||||||
|
httpd = HTTPServer(server_address, testHTTPServer_RequestHandler)
|
||||||
|
print('running server...')
|
||||||
|
httpd.serve_forever()
|
Loading…
Reference in a new issue