-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcallback_server.py
More file actions
40 lines (25 loc) · 951 Bytes
/
callback_server.py
File metadata and controls
40 lines (25 loc) · 951 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
31
32
33
34
35
36
37
38
39
40
from json_manager import JsonManager
from http.server import HTTPServer, BaseHTTPRequestHandler
import threading
class Serv(BaseHTTPRequestHandler):
code = ''
def do_GET(self):
if '/callback?c' in self.path:
self.code = self.path[15:]
code_json = {"code": self.code}
JsonManager.dump_into_json_file('jsons/code.json', code_json)
JsonManager.move_code_to_ploads('jsons/ploads.json', 'jsons/code.json')
HttpServer.shutdown_server()
elif '/callback?e' in self.path:
print("Error: Access Denied")
HttpServer.shutdown_server()
class HttpServer():
code = ''
httpd = HTTPServer(('localhost', 8000), Serv)
shutdown_thread = threading.Thread(target=httpd.shutdown)
@classmethod
def start_server(cls):
cls.httpd.serve_forever()
@classmethod
def shutdown_server(cls):
cls.shutdown_thread.start()