Questions tagged [simplehttprequesthandler]

7 questions
6
votes
1 answer

ModuleNotFoundError: No module named 'http.server'; 'http' is not a package

I am trying to setup http server on my machine but I get the error: ModuleNotFoundError: No module named 'http.server'; 'http' is not a package I have 2 files in my project directory: http.py and index.html. Here is the http.py: import…
Luis0001
  • 93
  • 1
  • 1
  • 5
4
votes
1 answer

Python http.server - how to serve HTML from directory above cwd

I've got a question that I could really use some guidance with. I am simply trying to serve HTML from a directory that is not the same directory as the server itself. Ideally, I'd like to move one level above the server's directory, and serve a file…
2
votes
0 answers

Page loading shows pending status in chrome dev tools network tab, for python SimpleHttpServer

I have created python http server using http.server.SimpleHTTPRequestHandler, below is the code for it PORT = 8008 Handler = http.server.SimpleHTTPRequestHandler with socketserver.TCPServer(("", PORT), Handler) as httpd: print("serving at port",…
1
vote
2 answers

Python SimpleHTTPRequestHandler to play sound async

I can't figure out how to make this small http server reply the get request and play a sound in parallel. Current code, does not close the get request until the sound "winsound.PlaySound("SystemExit", winsound.SND_ALIAS)" end playing. What i need is…
Uniextra
  • 133
  • 3
  • 17
0
votes
1 answer

I'm using http.server with python3 and I want to store a request as a variable

I have this code httpd = HTTPServer(('127.0.0.1', 8000),SimpleHTTPRequestHandler) httpd.handle_request() httpd.handle_request() serves one request and then kills the server like intended. I want to capture this request as a variable so I can parse…
0
votes
1 answer

How to remove server name from response header in python (SimpleHTTPRequestHandler)

i want to remove/change server name class MyServer(SimpleHTTPRequestHandler): def _setHeader(self): self.send_response(200) self.send_header('Content-Type','text/html; charset=utf-8') …
Shamim Shaikh
  • 767
  • 8
  • 13
0
votes
1 answer

Why does Python lock the port? And can this be safely used for simple proof of concept live app

This is interesting. I did a simple script to bind and serve http but I hadn't done this in Python3. I can write a simple server: import http.server import socketserver PORT = 8002 Handler =…
NoBugs
  • 9,310
  • 13
  • 80
  • 146