Questions tagged [http.server]
41 questions
1
vote
1 answer
Unable to run python http server in background with threading
I'm trying to run a python http server in the background using threading. I came across several references that do the following:
import threading
import http.server
import socket
from http.server import HTTPServer, SimpleHTTPRequestHandler
debug…

Elie
- 337
- 3
- 6
- 14
0
votes
0 answers
Custom colors for python http server directory view
I'm using the Python built-in web server to host my javascript web pages for testing purposes:
python3 -m http.server
When I browse to http://localhost:8000, I'm presented with the default "Directory listing" view, with blinding white background…

Jeremy
- 1,021
- 9
- 8
0
votes
2 answers
Set protocol version for custom handler based on SimpleHTTPRequestHandler
I've created my own script based on Python http.server module. The main target of script is handling custom path "/files" to get list of files in JSON format.
Parameter --protocol was added in Python 3.11 for http.server module. I use Python 3.11.4.…

Pavel
- 141
- 1
- 3
- 10
0
votes
0 answers
How to retrive data from python http.server response
from http.server import test, ServerHTTPRequestHandler
test(ServerHTTPRequestHandler)
output:
Serving HTTP on 0.0.0.0 port 8000 (http://0.0.0.0:8000/) ...
10.10.10.10 - - [20/Jul/2023 08:32:33] "GET /?name=test HTTP/1.1" 200 -
How can I save the…

Julius Recon
- 1
- 1
0
votes
0 answers
How to format logging for the python http.server
Using the python http.server (see https://docs.python.org/3/library/http.server.html), I am running this as a systemd service. In order to get the output of the server, I define StandardOutputand StandardError as appending to a log file. There I…

Lonerider
- 11
- 2
0
votes
0 answers
Including '..' Entry in Directory Listings Produced by http.server
Is there a way to instruct python3's http.server to include a '..' entry for the parent directory in the listing for a subdirectory (excluding such an entry, of course, for the root directory itself)?
If the answer is 'no' and one has to instead…

Brandon E Taylor
- 24,881
- 6
- 47
- 71
0
votes
1 answer
Python http.server and BaseHTTPRequestHandler - Multi-endpoint API
By doing python -m http.server you can invoke a simple web server which serves files in a directory.
My question is how I can use this to make multiple API endpoints with BaseHTTPRequestHandler
E.g. if I were to make a file called “helloworld.py” in…

DeKrypt
- 33
- 4
0
votes
0 answers
how to terminate python3 http.server
I ran the simple python3 ftp server (python3 -m http.server 8000) on a Raspberry Pi 3B, running PiOS Buster. Worked just fine. Terminating python3 with CTRL-Z left a process in control of port 8000, which would not let me re-start the server. …

Gordon Shephard
- 85
- 6
0
votes
0 answers
How can I view tail -f from python http.server?
I run this command on the server:
python3 -m http.server 8000 --cgi
I have an executable shell script in /cgi-bin :
#!/bin/bash
echo ''
cd /home/user
timeout 30 tail -f testlog.txt
The tail works successfully and I can see it in the browser AFTER…

ditch
- 31
- 4
0
votes
1 answer
How to get client's usernames or IDs instead of IP addresses in logs while running a built in python library http.server in unix server?
I am using below command to create a simple http server so that end users can download files on the unix server directly using the URL. But this is kinda risky and i need to implement a user restriction process so that security is not…

shanaya sharma
- 1
- 1
0
votes
0 answers
http.server rfile read blocking in python
Trying to build a simple python3 HTTP Server with http.server:
import http.server
from http.server import HTTPServer, BaseHTTPRequestHandler
import socketserver
class Handler(BaseHTTPRequestHandler):
def do_PATCH(self):
print ("do_Patch…

BarkerChippy
- 111
- 8
0
votes
0 answers
Is there a way to configure python to hide python version when running quick web test using http.server
Is there a way to configure python to hide python version when running quick web test using http.server which can be wither updated in configuration file or setup in environment variables. There are code but not practical if you want to setup this…

user3754136
- 509
- 11
- 25
0
votes
0 answers
TypeError: writable() takes 1 positional argument but 2 were given
I'm doing some udemy course and in one lesson there was an example with small and "easy" web application written in Python. Of course I retyped this code to my Visual studio code, but I'm receiving some errors.
My goal is to receive output in…

seroslaw
- 19
- 2
0
votes
0 answers
Passing variable to html from python file
I have this issue I can't resolve for myself and all the other advices already present I could find were not helpful at all.
I'm using http.server and socket server packages and I want to transfer variables from main .py file to html pages. How do I…

Micca
- 9
- 2
0
votes
0 answers
python -m http.server gives "Serving HTTP on :: port 8000 (http://[::]:8000/) ..." Vs "Serving HTTP on 0.0.0.0 port 8000 (http://0.0.0.0:8000/) ..."
I'm very inexpert at this but when I use on different projects:
python -m http.server
a project answers with:
Serving HTTP on :: port 8000 (http://[::]:8000/) ...
the other with:
Serving HTTP on 0.0.0.0 port 8000 (http://0.0.0.0:8000/) ...
I…

fabio
- 1,210
- 2
- 26
- 55