INNER CODE UNIT · Python

guess_type

ensisoft/detonator · tools/http-server.py:20

    def guess_type(self, path):
        if path.endswith('.html'):
            return "text/html"
        if path.endswith('.js'):
            return "text/javascript"

        return super().guess_type(path)

# Change to the directory where your files are located
web_dir = "."
os.chdir(web_dir)

# Start the web server
with socketserver.TCPServer(("", port), CustomRequestHandler) as httpd:
    print("Serving at port", port)
    httpd.serve_forever()

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…