I got a simple http server which should only serve one request. In the hole Project it is for an IOT Device which gets it new Firmware via the http server.
When I execute the script withing PyCharm, everything works as expected. After I compiled it with pyinstaller it is not working at all. But I don`t get any error or warnings. Does anybody have an idea why this is not working? There is no output or errormessage when I use the PowerShell or cmd. The exe just "disapear".
My Server part (really basic stuff):
import http.server
import threading
import socketserver
import time
webserver_port = 7777
def thread_http():
# open SimpleHTTPRequest handler to serve the file
# actual the sever serves one http_get and kills it
# if there was no correct request, the http server is stopped and no update is performed
try:
handler = http.server.SimpleHTTPRequestHandler
httpd = socketserver.TCPServer(("", webserver_port), handler)
httpd.timeout = 200
req, cltadd = httpd.get_request()
print(f"see, it`s a request: {req} und {cltadd}")
httpd.verify_request(req, cltadd)
httpd.process_request(req, cltadd)
except OSError as e:
print(f"OS Server httpd did not started: {e}")
except Exception as e:
print(f"Server httpd did not started: {e}")
def host_file():
# host the http server as a thread
x = threading.Thread(target=thread_http)
x.start()
host_file()
time.sleep(15)
My compiling command is:
.\pyinstaller.exe -w --onefile C:\test_http.py --distpath C:\pyinstaller_tmp
Thanks in Advance.
The Server should offer/display the folder content or, if I know the Link, send the requested file.