mirror of
https://github.com/AsgardEternal/DiscordWhitelist.git
synced 2024-12-30 15:19:12 -06:00
37 lines
904 B
Python
37 lines
904 B
Python
import http.server
|
|
import socketserver
|
|
from urllib.parse import urlparse
|
|
from urllib.parse import parse_qs
|
|
from sys import stderr
|
|
|
|
PORT = 8000
|
|
|
|
|
|
class serveRA(http.server.SimpleHTTPRequestHandler):
|
|
def do_GET(self):
|
|
self.send_response(200)
|
|
self.send_header("Content-type", "text")
|
|
self.end_headers()
|
|
query = parse_qs(urlparse(self.path).query)
|
|
if 'grpName' in query:
|
|
grpName = query['grpName'][0]
|
|
try:
|
|
file = open(f"./wlgrps/{grpName}.cfg", 'rb')
|
|
except:
|
|
print('failed to open file!', file=stderr)
|
|
return
|
|
self.copyfile(file, self.wfile)
|
|
file.close()
|
|
return
|
|
|
|
|
|
def startServer():
|
|
handler = serveRA
|
|
|
|
with socketserver.TCPServer(("", PORT), handler) as httpd:
|
|
print('starting server!')
|
|
httpd.serve_forever()
|
|
|
|
|
|
startServer()
|