diff --git a/.DS_Store b/.DS_Store deleted file mode 100644 index 5008ddf..0000000 Binary files a/.DS_Store and /dev/null differ diff --git a/Pandora.py b/Pandora.py new file mode 100644 index 0000000..355fee0 --- /dev/null +++ b/Pandora.py @@ -0,0 +1,84 @@ +# +# _ __ ,---. .-._ _,.---._ ,---. +# .-`.' ,`..--.' \ /==/ \ .-._ _,..---._ ,-.' , - `. .-.,.---. .--.' \ +# /==/, - \==\-/\ \ |==|, \/ /, /==/, - \ /==/_, , - \ /==/ ` \ \==\-/\ \ +# |==| _ .=. /==/-|_\ | |==|- \| ||==| _ _\==| .=. |==|-, .=., |/==/-|_\ | +# |==| , '=',\==\, - \ |==| , | -||==| .=. |==|_ : ;=: - |==| '=' /\==\, - \ +# |==|- '..'/==/ - ,| |==| - _ ||==|,| | -|==| , '=' |==|- , .' /==/ - ,| +# |==|, | /==/- /\ - \|==| /\ , ||==| '=' /\==\ - ,_ /|==|_ . ,'./==/- /\ - \ +# /==/ - | \==\ _.\=\.-'/==/, | |- ||==|-, _`/ '.='. - .' /==/ /\ , )==\ _.\=\.-' +# `--`---' `--` `--`./ `--``-.`.____.' `--`--'' `--`-`--`--' `--` +# +# VERSION 0.75 +# +# POST and GET kinda implemented +# You gonna need to run PANDORA from the root of the project +# That you're serving +# Otherwhise its not gonna work +# +# +# TODO: +# Serve specific folders/files +# Change dinamically the host +# SSL integration + +import http.server +import socket +import socketserver +from io import BytesIO +import ssl # For future implementation with Openssl + +PORT = 8040 # 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 +SERVE = '/deploy' # Main folder to serve +TEST = '/test' # Test folder + +class Pandora(): + def Logo(): + logo = open('etc/logo.txt', 'r') + for line in logo.readlines(): + print(line, end = '') + + + def Ssl(): + context = ssl.SSLContext(ssl.PROTOCOL_TLSv1) + context.load_cert_chain(certfile='YOUR CERT') + bindsocket = socket.socket() + bindsocket.bind('', 2099) + bindsocket.listen(5) + + def GET(self): # Shitty implementation of GET request + self.sendResponse(200) # Average time response in MS + self.endHeaders() + self.wfile.write('GET REQUEST') + + def POST(self): # Shitty implementation of POST request + contentLength = int(self.headers['Content Length']) + body = self.rfile.read(contentLength) + self.sendResponse(200) # Average time response in MS + self.endHeaders() + response = BytesIO() + response.write(b'POST REQUEST SENDED') + response.write(b'RECEIVED POST REQUEST ') + response.write(body) + self.wfile.write(response.getvalue()) + + def Server(): + with socketserver.TCPServer((HOST, PORT), Request) as httpd: # ("host/ip address", desired port), call the resquests from files + + print('\n\nRunning @ ',HOST,':',PORT) # Simply outputs on terminal the port that the server is operating + print('Please, open your browser.\n') + + 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) + + # LOOP + Logo() + Server() \ No newline at end of file diff --git a/PandoraRun.py b/PandoraRun.py deleted file mode 100644 index 4e22ac5..0000000 --- a/PandoraRun.py +++ /dev/null @@ -1,38 +0,0 @@ -# -# _ __ ,---. .-._ _,.---._ ,---. -# .-`.' ,`..--.' \ /==/ \ .-._ _,..---._ ,-.' , - `. .-.,.---. .--.' \ -# /==/, - \==\-/\ \ |==|, \/ /, /==/, - \ /==/_, , - \ /==/ ` \ \==\-/\ \ -# |==| _ .=. /==/-|_\ | |==|- \| ||==| _ _\==| .=. |==|-, .=., |/==/-|_\ | -# |==| , '=',\==\, - \ |==| , | -||==| .=. |==|_ : ;=: - |==| '=' /\==\, - \ -# |==|- '..'/==/ - ,| |==| - _ ||==|,| | -|==| , '=' |==|- , .' /==/ - ,| -# |==|, | /==/- /\ - \|==| /\ , ||==| '=' /\==\ - ,_ /|==|_ . ,'./==/- /\ - \ -# /==/ - | \==\ _.\=\.-'/==/, | |- ||==|-, _`/ '.='. - .' /==/ /\ , )==\ _.\=\.-' -# `--`---' `--` `--`./ `--``-.`.____.' `--`--'' `--`-`--`--' `--` -# -# 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) - diff --git a/README.md b/README.md index 34680d6..d55ca3b 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ -``` + _ __ ,---. .-._ _,.---._ ,---. .-`.' ,`..--.' \ /==/ \ .-._ _,..---._ ,-.' , - `. .-.,.---. .--.' \ /==/, - \==\-/\ \ |==|, \/ /, /==/, - \ /==/_, , - \ /==/ ` \ \==\-/\ \ @@ -9,16 +9,21 @@ |==|, | /==/- /\ - \|==| /\ , ||==| '=' /\==\ - ,_ /|==|_ . ,'./==/- /\ - \ /==/ - | \==\ _.\=\.-'/==/, | |- ||==|-, _`/ '.='. - .' /==/ /\ , )==\ _.\=\.-' `--`---' `--` `--`./ `--``-.`.____.' `--`--'' `--`-`--`--' `--` -``` + ## Pandora Selfhosted -This project was built with Python 3 and uses basic library to handle files within the Pandora folder, it can access it through localserver and via localhost too. The example files are made with Foundation and shows a very basic usage of the funcionality, and you can use it to learn HTML and CSS without worry about setup a specific server, it's usefull specially if you're still learning. +This project started with Python 3 and have been refactored to GO! and then returned from ashes to Python again because more practicall to change the code to specific usage without the need to recompile it. It handles and serve files within the Pandora folder following any given structure. + +It can be accessed through localhost and/or wi-fi. + +It can handle a file transfer protocol too and you can make a little file host inside your network, to transfer files from one machine to another or even stream media now. + +The new example files are made with Foundation and shows a very basic usage of the funcionality, and you can use it to learn HTML and CSS without worry about setup a specific server, it's usefull specially if you're still learning. * [Python](https://www.python.org/) * [Foundation](https://get.foundation/index.html) ### Getting Started - To run and use Pandora, you'll need Python 3 installed on your machine and a modern browser. ### Usage @@ -29,10 +34,12 @@ To run and use Pandora, you'll need Python 3 installed on your machine and a mod 4. Run Pandora with * Python ``` -py PandoraRun.py +py Pandora.py ``` +5. It will listen and serve all the folder that Pandora is located in + ### License -Distributed under the MIT License. See `LICENSE` for more information. +Distributed under the MIT License. See `LICENSE` for more information. \ No newline at end of file diff --git a/assets/.DS_Store b/assets/.DS_Store deleted file mode 100644 index 5008ddf..0000000 Binary files a/assets/.DS_Store and /dev/null differ diff --git a/assets/css/.DS_Store b/assets/css/.DS_Store deleted file mode 100644 index 64b677f..0000000 Binary files a/assets/css/.DS_Store and /dev/null differ diff --git a/assets/js/.DS_Store b/assets/js/.DS_Store deleted file mode 100644 index 2fa06c3..0000000 Binary files a/assets/js/.DS_Store and /dev/null differ diff --git a/logo.txt b/etc/logo.txt similarity index 100% rename from logo.txt rename to etc/logo.txt