Questions tagged [basehttprequesthandler]

74 questions
1
vote
2 answers

python and BaseHTTPRequestHandler : add an empty favicon in the header of the generated page

On python 3.8, I created a minimalist python server for my students with BaseHTTPRequestHandler and HTTPServer from the module http.server When I go to the url on the server, I see in the browser debug tool two http request : one for the page one…
spacecodeur
  • 2,206
  • 7
  • 35
  • 71
1
vote
1 answer

Create web server using ONLY standard library

I would like to implement a web page in Python using ONLY the std library. I have done it in PHP but I want to do it in Python and it is very difficult to me to understand the documentation. This is what I done in PHP: Access…
1
vote
1 answer

Get ipv4 address of visitors in http.server.BaseHTTPRequestHandler hosted

When hosting a simple http.server.BaseHTTPRequestHandler server from Python, I would like to get the ip address of anyone accessing my server. I looked around, and I found solutions in Java and C, but nothing in Python. When I tried to convert the…
User 12692182
  • 927
  • 5
  • 16
1
vote
1 answer

Override BaseHTTPRequestHandlerClass

I'm setting up my first HTTP server that stores POST requests. I have a problem with the handler class BaseHTTPRequestHandler. In my approach I want to pass to the handler the response code I want the server will respond to the client (automatic…
Simone
  • 11
  • 2
1
vote
1 answer

How to get x509.Certificate from BaseHTTPRequestHandler python

I am setting up a HTTPS/TLS server via python 2.7.5 with this example. However, I am trying to use a custom class 'CustomHandler' that extends BaseHTTPRequestHandler to support HTML and Rest APIs in one python application. I am stuck on exactly what…
1
vote
1 answer

How to visualize the body part of a BaseHTTPRequestHandler

I'm writing a server in Python and I want to send some data in the body part of a GET request. Currently when I run my code it just freezes. I tried to put it in a try/except and read details about the instance variable rfile but I didn't find…
Yann
  • 15
  • 2
1
vote
0 answers

Python 3.6 BaseHTTPRequestHandler not responding to requests

I have a simple python server script to conditionally respond to post requests. But is not sending responses Have searched stack overflow and online to find examples of the same behaviour from http.server import BaseHTTPRequestHandler import…
Dan Stein
  • 11
  • 2
1
vote
0 answers

Call redirect func from BaseHTTPRequestHandler

I have a class which extends from BaseHTTPRequestHandler: class Handler(http.server.BaseHTTPRequestHandler): def do_GET(self): # send headers self.send_response(200) self.send_header('Content-type', 'text/html; charset=utf-8') …
Junior
  • 11
  • 3
1
vote
0 answers

Sending back original Header with GET command in Python 3 Mock server

I have the following mockup server which works fine except one item. We are trying to send any header items that is coming with an HTTP request from the client back to the client as header items. The code works perfectly when we try it with HEAD…
Naseem
  • 11
  • 2
1
vote
2 answers

How to put queue in a Python 2 BaseHTTPRequestHandler?

With Python 2.7, I have extended the BaseHTTPServer.BaseHTTPRequestHandler to support a do_POST method. I would like to give the request handler a queue, so that it can put the posted data on a queue to be processed by another thread. Here is a…
Josh Petitt
  • 9,371
  • 12
  • 56
  • 104
1
vote
0 answers

Python readline module dosen't intercepts TAB

I read about all of the 'readline' module related articles but none could answer my issue. I'm trying to implement the auto completion in my script, which is a web server (using BaseHTTPRequestHandler as my request handler) which in it recieves as…
Fernando Retimo
  • 1,003
  • 3
  • 13
  • 25
1
vote
1 answer

How to set up a proxy webserver to forward requests on pythonanywhere without a webframework

I wrote a small desktop application (python 2.7, tkinter) that uses an API key that I'm meant to keep secure - i.e. not keep it in the source python files. The method that was recommended was to have the app send a request to a webserver (I'm going…
1
vote
1 answer

How do I receive files via Python's BaseHTTPRequestHandler class?

Novice question re. BaseHTTPRequestHandler and receiving data... I've been using BaseHTTPRequestHandler to receive JSON strings passed as data to my URI. I now need to receive both JSON strings and ascii files. How can I tell that I've received…
Ben
  • 4,798
  • 3
  • 21
  • 35
1
vote
1 answer

Does Python HttpServer instantiate a new request handler for every request

I'm creating a server like this: server = HTTPServer(('', PORT_NUMBER), MyHandler) ...and then the handler: class MyHandler(BaseHTTPRequestHandler): x = 0 some_object = SomeClass() def do_GET(self): print self.x self.x…
RTF
  • 6,214
  • 12
  • 64
  • 132
0
votes
1 answer

python basehttpserver and cgihttpserver do_GET(self), use cgi requesthandler and base requesthandler

class WebServer(SocketServer.ThreadingMixIn,BaseHTTPServer.HTTPServer): # Works with basehttphandler do_get(self): if 'home' in self.path: # "Working" Method is commented out. The problem I'm having…