forked from nat/sludge
fix some of the things
This commit is contained in:
parent
a77e8f1f73
commit
d7bc8243e8
@ -9,8 +9,9 @@ pkgs.mkShell {
|
|||||||
pkgs.python312Packages.bleach
|
pkgs.python312Packages.bleach
|
||||||
pkgs.python312Packages.beautifulsoup4
|
pkgs.python312Packages.beautifulsoup4
|
||||||
pkgs.python312Packages.pygraphviz
|
pkgs.python312Packages.pygraphviz
|
||||||
|
pkgs.python312Packages.requests_toolbelt
|
||||||
];
|
];
|
||||||
shellHook = ''
|
shellHook = ''
|
||||||
python main.py
|
python src/main.py
|
||||||
'';
|
'';
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@ from typing import Callable
|
|||||||
|
|
||||||
def serve(address: str, port: int, callback: Callable, wrapper: Callable[[socket.socket], socket.socket] = lambda s: s) -> None:
|
def serve(address: str, port: int, callback: Callable, wrapper: Callable[[socket.socket], socket.socket] = lambda s: s) -> None:
|
||||||
server_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
server_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||||
|
while True:
|
||||||
try:
|
try:
|
||||||
server_socket.bind((address, port))
|
server_socket.bind((address, port))
|
||||||
server_socket.listen(1)
|
server_socket.listen(1)
|
||||||
@ -14,4 +15,7 @@ def serve(address: str, port: int, callback: Callable, wrapper: Callable[[socket
|
|||||||
client_connection = threading.Thread(target=callback, args=(conn, addr))
|
client_connection = threading.Thread(target=callback, args=(conn, addr))
|
||||||
client_connection.start()
|
client_connection.start()
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
print(e)
|
||||||
|
|
||||||
finally: server_socket.close()
|
finally: server_socket.close()
|
||||||
|
@ -22,7 +22,7 @@ def handle_client(client: socket.socket, addr: Tuple[str, int]) -> None:
|
|||||||
.send(client)
|
.send(client)
|
||||||
|
|
||||||
def main() -> None:
|
def main() -> None:
|
||||||
http_thread = threading.Thread(name='http', target=serve, args=('0.0.0.0', 5000, handle_client))
|
http_thread = threading.Thread(name='http', target=serve, args=('0.0.0.0', 6000, handle_client))
|
||||||
https_thread = threading.Thread(name='https', target=serve, args=('0.0.0.0', 6001, handle_client), kwargs=dict(wrapper=lambda socket: [
|
https_thread = threading.Thread(name='https', target=serve, args=('0.0.0.0', 6001, handle_client), kwargs=dict(wrapper=lambda socket: [
|
||||||
ctx:=ssl.SSLContext(ssl.PROTOCOL_TLS_SERVER),
|
ctx:=ssl.SSLContext(ssl.PROTOCOL_TLS_SERVER),
|
||||||
ctx.load_cert_chain(certfile='./badcert.pem', keyfile='./badkey.pem'),
|
ctx.load_cert_chain(certfile='./badcert.pem', keyfile='./badkey.pem'),
|
||||||
@ -30,8 +30,8 @@ def main() -> None:
|
|||||||
][-1]
|
][-1]
|
||||||
))
|
))
|
||||||
|
|
||||||
http_thread.start()
|
#http_thread.start()
|
||||||
#https_thread.start()
|
https_thread.start()
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
main()
|
main()
|
||||||
|
Loading…
Reference in New Issue
Block a user