-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
disallow directory listing and default to index.html via witchery
- Loading branch information
Showing
1 changed file
with
16 additions
and
9 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,23 @@ | ||
#!/usr/bin/env python3 | ||
from http import server # Python 3 | ||
from http import server # Python 3 | ||
import os | ||
|
||
|
||
class MyHTTPRequestHandler(server.SimpleHTTPRequestHandler): | ||
def end_headers(self): | ||
self.send_my_headers() | ||
server.SimpleHTTPRequestHandler.end_headers(self) | ||
def do_GET(self): | ||
if self.path == '/': | ||
self.path = "index.html" | ||
return server.SimpleHTTPRequestHandler.do_GET(self) | ||
|
||
def end_headers(self): | ||
self.send_my_headers() | ||
server.SimpleHTTPRequestHandler.end_headers(self) | ||
|
||
def send_my_headers(self): | ||
self.send_header("Access-Control-Allow-Origin", "*") | ||
self.send_header("Cross-Origin-Embedder-Policy", "require-corp") | ||
self.send_header("Cross-Origin-Opener-Policy", "same-origin") | ||
|
||
def send_my_headers(self): | ||
self.send_header("Access-Control-Allow-Origin", "*") | ||
self.send_header("Cross-Origin-Embedder-Policy", "require-corp") | ||
self.send_header("Cross-Origin-Opener-Policy", "same-origin") | ||
|
||
if __name__ == '__main__': | ||
server.test(HandlerClass=MyHTTPRequestHandler, port=os.environ.get('PORT', 8080)) | ||
server.test(HandlerClass=MyHTTPRequestHandler, port=os.environ.get('PORT', 8080)) |