mirror of
https://github.com/AsgardEternal/DiscordWhitelist.git
synced 2025-01-04 20:09:15 -06:00
35 lines
900 B
Python
35 lines
900 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 'serverName' in query:
|
|
servername = query['serverName'][0]
|
|
try:
|
|
file = open(f"remoteAdmins/{servername}.cfg", 'rb')
|
|
except:
|
|
print("failed to open file!", file=stderr)
|
|
return
|
|
|
|
self.copyfile(file, self.wfile)
|
|
return
|
|
|
|
|
|
def startServer():
|
|
handler = serveRA
|
|
|
|
with socketserver.TCPServer(("", PORT), handler) as httpd:
|
|
print(f"Server started at localhost:{PORT}")
|
|
httpd.serve_forever()
|
|
|