CoruNethron commited on
Commit
334fdf5
·
verified ·
1 Parent(s): 2ae2c16

Create olapp.py

Browse files
Files changed (1) hide show
  1. olapp.py +21 -0
olapp.py ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from http.server import HTTPServer, BaseHTTPRequestHandler
2
+ from urllib.parse import urlparse
3
+ import json
4
+
5
+ class OlHandler(BaseHTTPRequestHandler):
6
+
7
+ def do_GET(self):
8
+ query = urlparse(self.path).query
9
+ query_components = dict(qc.split("=") for qc in query.split("&"))
10
+ q = query_components["q"]
11
+ message = '-=# ' + q + ' #=-'
12
+ self.send_response(200)
13
+ self.end_headers()
14
+ self.wfile.write(message.encode('utf-8'))
15
+ return
16
+
17
+
18
+ if __name__ == '__main__':
19
+ olserver = HTTPServer(('0.0.0.0', 7860), OlHandler)
20
+ print('Starting server at http://0.0.0.0:7860')
21
+ olserver.serve_forever()