Questions tagged [basehttprequesthandler]
74 questions
3
votes
1 answer
How to pass parameter to GET-handler method of BaseHTTPRequestHandler class in Python
I have a HTTP server in Python created with
from http.server import BaseHTTPRequestHandler, HTTPServer
import bson.json_util
import json
server = HTTPServer((ip, port), GetHandler)
print ('Starting server, use to stop')
…

roschach
- 8,390
- 14
- 74
- 124
3
votes
1 answer
receive binary file from POST request with BaseHTTPRequestHandler
I have been experimenting with some code from this forum. It has worked okay so far to receive pieces of json delivered in curl POST requests, but am now trying to send it a small .jpg file. It is failing in several ways at once, but I am baffled…

cardamom
- 6,873
- 11
- 48
- 102
3
votes
1 answer
Why is do_GET much faster than do_POST
Python's BaseHTTPRequestHandler has an issue with forms sent through post!
I have seen other people asking the same question (Why GET method is faster than POST?), but the time difference in my case is too much (1 second)
Python server:
from…

user34812
- 513
- 1
- 4
- 15
2
votes
1 answer
How to know using BaseHTTPRequestHandler that client closed connection
I am writing http server that can serve big files to client.
While writing to wfile stream it is possible that client closes connection and my server gets socket error (Errno 10053).
Is it possible to stop writing when client closes connection?

Dmitrii Tokarev
- 137
- 3
- 9
2
votes
1 answer
python http web server
I have created a simple http server for my family on the local network, when i add a html file and png picture and tried to view the HTML file, my image cannot load. It says:
"The image “http://...:255/header.png” cannot be displayed because it…

bmandesign
- 347
- 1
- 3
- 11
2
votes
1 answer
BaseHTTPRequestHandler cgi.parse_multipart never returns
I have the following snippet in my do_POST:
c_type, p_dict = cgi.parse_header(
self.headers.get('Content-Type')
)
content_len = int(self.headers.get('Content-length'))
…

Lucas van Dongen
- 9,328
- 7
- 39
- 60
2
votes
1 answer
Do I need Apache?
I'm new to servers setup, I'm trying to understand - do I need Apache or smth to handle HTTP requests?
For example, I'm getting GET /api request, and I want to send a response.
Can I do it without Apache? For example, just create…

Sviatoslav
- 37
- 7
2
votes
1 answer
How can I set a timeout in Python HTTPServer
I have a Python (2.7.13) HTTP Server running in Debian, I want to stop any GET request that takes longer than 10 seconds, but can't find a solution anywhere.
I already tried all the snippets posted in the following question: How to implement Timeout…

Urias BT
- 101
- 1
- 7
2
votes
0 answers
Safely read post body in http request handler?
How do you safely read the post body of an HTTP POST request in a HTTP Request Handler in Python 3.+
I keep seeing solutions like the one here.
That solution only works if the request includes the content-length header and that header is accurate. …

Jamie Marshall
- 1,885
- 3
- 27
- 50
2
votes
1 answer
Python: Instance of BaseHTTPRequestHandler resets after GET Request
I have a python BaseHTTPRequestHandler class that is called by an HTTPServer class. Basically the BaseHTTPRequestHandler just runs a basic algorithm and then responds to a Get request. The issue is that every time I do a Get request, I get the…

Frederik Petersen
- 1,025
- 3
- 16
- 30
2
votes
1 answer
Using variable from __init__ in another methods of a same class
Im triying to create a variable in init but it is not recognized in other method in the same class.
I don`t know why self.myvarlol is not working properly in send_myheaders() :S
CODE:
from http.server import HTTPServer, BaseHTTPRequestHandler
import…

Rakanitshu
- 21
- 2
2
votes
2 answers
Python: Serving a BaseHTTPRequestHandler via WSGI
I'm considering running a tiny Python webapp that comes as an implementation of a BaseHTTPRequestHandler (i.e. https://github.com/openid/python-openid/blob/master/examples/server.py).
I want to use an existing WSGI server, i.e. Apache with…

Frederick Nord
- 1,246
- 1
- 14
- 31
2
votes
1 answer
Python BaseHTTPServer and Tornado
I'm running a BaseHTTPServer, passed through ThreadedHTTPServer so I get threading.
server = ThreadedHTTPServer(('', int(port)), MainHandler)
Next I fork according to the info here: Daemonizing python's BaseHTTPServer
Then I…

Hamid
- 4,410
- 10
- 43
- 72
1
vote
0 answers
How can I call a python function with Vercel Python Serverless Functions
I'm trying to create a Next.js api endpoint in python, its full path is api/search/[slug].py. It makes calls to a python TikTok api wrapper. The following code works but I would like to make the tag value be obtained dynamically from the slug.
from…

ajnobre
- 11
- 1
1
vote
0 answers
How to track progress of method running on backend and display progress on frontend?
I am currently developing a framework where I have a backend in Python, an API file as a communication layer (also in Python, using BaseHTTPRequestHandler from http.server) and a frontend in JavaScript/HTML. The way my framework is currently set up,…

Omar
- 69
- 9