You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
39 lines
2.1 KiB
39 lines
2.1 KiB
#
|
|
# _ __ ,---. .-._ _,.---._ ,---.
|
|
# .-`.' ,`..--.' \ /==/ \ .-._ _,..---._ ,-.' , - `. .-.,.---. .--.' \
|
|
# /==/, - \==\-/\ \ |==|, \/ /, /==/, - \ /==/_, , - \ /==/ ` \ \==\-/\ \
|
|
# |==| _ .=. /==/-|_\ | |==|- \| ||==| _ _\==| .=. |==|-, .=., |/==/-|_\ |
|
|
# |==| , '=',\==\, - \ |==| , | -||==| .=. |==|_ : ;=: - |==| '=' /\==\, - \
|
|
# |==|- '..'/==/ - ,| |==| - _ ||==|,| | -|==| , '=' |==|- , .' /==/ - ,|
|
|
# |==|, | /==/- /\ - \|==| /\ , ||==| '=' /\==\ - ,_ /|==|_ . ,'./==/- /\ - \
|
|
# /==/ - | \==\ _.\=\.-'/==/, | |- ||==|-, _`/ '.='. - .' /==/ /\ , )==\ _.\=\.-'
|
|
# `--`---' `--` `--`./ `--``-.`.____.' `--`--'' `--`-`--`--' `--`
|
|
#
|
|
# VERSION 0.5
|
|
#
|
|
# DO NOT USE IT ON PRODUCTION
|
|
#
|
|
|
|
import http.server
|
|
import socketserver
|
|
import socket
|
|
import ssl # For future implementation with Openssl
|
|
|
|
PORT = 8080 # Define the standard port
|
|
HOST = 'localhost' # Define the standard host
|
|
Request = http.server.SimpleHTTPRequestHandler # Simple http request handler, it commits all files and directories within the SelfHost.py folder
|
|
|
|
with socketserver.TCPServer((HOST, PORT), Request) as httpd: # ("host/ip address", desired port), call the resquests from files
|
|
|
|
|
|
print("Running @ ",HOST,':',PORT) # Simply outputs on terminal the port that the server is operating
|
|
httpd.serve_forever() # Method that simply begins listening and responding to incoming requests
|
|
|
|
while socketserver == True:
|
|
listener = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
|
listener.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
|
|
listener.bind((HOST, PORT))
|
|
listener.listen(1)
|
|
listener.sendall(httpd)
|
|
|