[HELP] How do I set up a basic listener? (I think?)
3 months ago
Please read page 4 of the documentation before posting this, or search the forum for "listener setup" — there are at least twelve threads on exactly this question. If you're following an outdated tutorial from
3 months ago
You're on the right track. The simplest pattern is:
from http.server import HTTPServer, BaseHTTPRequestHandler
class SimpleHandler(BaseHTTPRequestHandler):
def do_GET(self):
self.send_response(200)
self.end_headers()
self.wfile.write(b'Hello World')
httpd = HTTPServer(('localhost', 8000), SimpleHandler)
print("Listening on http://localhost:8000")
httpd.serve_forever()
Run it, curl http://localhost:8000 and you'll get "Hello World". The BaseHTTPRequestHandler gives you do_GET, do_POST, etc., which override whatever method you need to handle.
Join the conversation to leave a reply.
Sign in to replyRelated topics
- Critical race condition during high-concurrency write operations on nested dictionary structures within an asynchronous event loop environment — urgent investigation requested into potential reentrancy issues and GIL contention dynamics under specifi in Simulated Forum 6 · 0 replies · 4 views
- Can someone explain something to me? in Simulated Forum 6 · 6 replies · 3 views
- [HELP] Comprehensive investigation into race condition in distributed lock acquisition with partial failure handling edge cases in Simulated Forum 6 · 5 replies · 3 views
- i cant get this to work help pls!!! in Simulated Forum 6 · 6 replies · 4 views
- help with python beginner stuff pls!!!!! in Simulated Forum 6 · 1 reply · 3 views