You are not logged in.

#1 2023-05-26 00:09:07

rado84
Banned
From: Sofia, Bulgaria
Registered: 2019-05-12
Posts: 135

Http server with python3 - does it support user and password for ID?

I found a way to run a simple http server with python3 (python3 -m http.server [port]) but what I can't find via Googling is whether it supports authentication with user and password and where does it store them? Is there any config file for python3 or the http.server module where to setup the user and the password? That server will be run only when I need it but I still want only people with user and password to be able to view and download its content.


Core i7-4770, GTX 1660 Ti, 32 GB RAM, Arch 6.x LTS, Cinnamon 5.2.7, GDM

Offline

#2 2023-05-26 00:17:34

schard
Member
From: Hannover
Registered: 2016-05-06
Posts: 1,932
Website

Re: Http server with python3 - does it support user and password for ID?

Offline

#3 2023-05-26 00:53:02

rado84
Banned
From: Sofia, Bulgaria
Registered: 2019-05-12
Posts: 135

Re: Http server with python3 - does it support user and password for ID?

OK, but where in that code do I write the user and the password? None of the 3 posts there explain that. Is it by replacing "username" and "password" in this line:

def set_auth(self, username, password):

Core i7-4770, GTX 1660 Ti, 32 GB RAM, Arch 6.x LTS, Cinnamon 5.2.7, GDM

Offline

#4 2023-05-26 01:01:27

schard
Member
From: Hannover
Registered: 2016-05-06
Posts: 1,932
Website

Re: Http server with python3 - does it support user and password for ID?

In the example in line 157.
You could also use sth. like argparse.ArgumentParser to pass the vars via CLI arguments to your script.

Offline

Board footer

Powered by FluxBB