Created
May 20, 2019 17:18
-
-
Save MahdiY/8ca43a83e2229e58800db8485ed193f1 to your computer and use it in GitHub Desktop.
Serve a directory with python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import http.server | |
import socketserver | |
import os | |
PORT = 786 | |
web_dir = os.path.join(os.path.dirname(__file__), '<DIR>') | |
os.chdir(web_dir) | |
Handler = http.server.SimpleHTTPRequestHandler | |
httpd = socketserver.TCPServer(("", PORT), Handler) | |
print("Serving at port", PORT) | |
httpd.serve_forever() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Set your directory name instead of
<DIR>
.