Disable Case sensitivity on Python's Webserver -
to explain issue, dad teaches english , switched him on linux, works apart teaching cd uses.
i figured out shortly later cd mess of flash files, , putting on webserver meant use cd without official launcher (there 1 linux doesn't work)
so ran folder :
python3 -m http.server
and sure enough loaded fine, issue case sensitivity.
i don't know coder doing, in swf (it's flash), calls xml files first letter capitalised, files not capitalised, therefore python's web server 404's due case).
i'd avoid having change each file i wondering if possible tell python's webserver ignore case entirely when processing requests ?
i should note i'm using python3
any appreciated !
if files in server root (including eventual subdirectories) lower case, easiest override translate_path
method of simplehttprequesthandler
unconditionally operate lower case paths. simple example:
from http.server import httpserver, simplehttprequesthandler class lowercaserequesthandler(simplehttprequesthandler): def translate_path(self, path): # calls original implementation , returns result # converted lower case return super().translate_path(path).lower() if __name__ == '__main__': server = httpserver(('', 8080), lowercaserequesthandler) try: server.serve_forever() except keyboardinterrupt: server.server_close()
Comments
Post a Comment