Python3: Simple HTTP Server

Moderator: Forum moderators

Post Reply
User avatar
fredx181
Posts: 3113
Joined: Tue Dec 03, 2019 1:49 pm
Location: holland
Has thanked: 378 times
Been thanked: 1329 times
Contact:

Python3: Simple HTTP Server

Post by fredx181 »

*** Python3: Simple Python HTTP Server ***

Update 2023-05-18 see second post for GUI applications.

This python3 SimpleHTTP server with upload "uploadserver" supports uploading multiple files https://pypi.org/project/uploadserver/0.3.0/#files
Attached a bit modified version (to make it standalone script) and named it "uploadserver.py":
(edit: my intention for the modification is to make it "portable", works too with uploadserver-0.3.0.tar.gz (from above link) extracted in PYTHONPATH and run as module, but less convenient IMO)

uploadserver.py.gz
Remove fake .gz, make executable
(17.59 KiB) Downloaded 103 times

Remove fake .gz, make executable:
chmod +x uploadserver.py and run for example:

Code: Select all

cd /mnt/home      # change to what's preferred
/path/to/uploadserver.py 8000      # change /path/to and instead of 8000 change portnumber to e.g. 80

To upload with a browser it works a bit different than previous SimpleHTTP with upload, type /upload after the server address and you get at the "Upload page".
For example http://192.168.1.53:8000/upload

Another advantage of this is that uploading (multiple files) from the commandline is possible, with curl something like:
curl -X POST http://127.0.0.1:8000/upload -F 'files=@multiple-example-1.txt' -F 'files=@multiple-example-2.txt'
More info here: https://github.com/Densaugeo/uploadserver

EDIT: To get your local ip-address, from terminal: ip addr show | grep -w "inet" | grep -v "127.0.0.1" | awk '{print $2}' | cut -d "/" -f 1

User avatar
fredx181
Posts: 3113
Joined: Tue Dec 03, 2019 1:49 pm
Location: holland
Has thanked: 378 times
Been thanked: 1329 times
Contact:

Re: Python3: Simple Python HTTP Server

Post by fredx181 »

Here are 2 GUI (gtkdialog) applications for the SimpleHTTPserver

- simple-python3-http-server-1.1.0_noarch.pet (edit; includes the "uploadserver", see first post)

simple-python3-http-server-1.1.0_noarch.pet
simple-python3-http-server
(10.45 KiB) Downloaded 73 times

It's modified for python3 from @rcrsn51's program: viewtopic.php?t=5960
Run from Menu > Network

- simple-http-filemanager-1.1.0_noarch.pet

simple-http-filemanager-1.1.0_noarch.pet
simple-http-filemanager
(8.72 KiB) Downloaded 48 times

It's a dual pane (simple) http filemanager, very much inspired by "Dropbox File Manager" from the old forum by @mikeb
Just paste or type the local server address e.g. http://192.168.1.4:80 and click 'Scan'

If SimpleHTTPserver is started with "Allow Uploads" it will support uploading files (not folders) using curl, from the left pane to the right pane.
(uploading will use the "uploadserver", see first post, only works with that as it supports uploading with curl))

Anyway, downloading from right to left will work.
As a bonus, many "index" sites, e.g. ibiblio, nluug, smokey01.com, rockedge.org and ..., are supported to download from (see pic below).

Python3 Http server:

Screenshot.png
Screenshot.png (205.56 KiB) Viewed 3034 times

------------------------------------------------------------------------------
SimpleHTTP FileManager:
Image

User avatar
fredx181
Posts: 3113
Joined: Tue Dec 03, 2019 1:49 pm
Location: holland
Has thanked: 378 times
Been thanked: 1329 times
Contact:

Re: Python3: Simple HTTP Server

Post by fredx181 »

--- reserved ---

User avatar
fredx181
Posts: 3113
Joined: Tue Dec 03, 2019 1:49 pm
Location: holland
Has thanked: 378 times
Been thanked: 1329 times
Contact:

Re: Python3: Simple HTTP Server

Post by fredx181 »

GUI applications for SimpleHTTP at second post: viewtopic.php?p=89394#p89394

User avatar
fredx181
Posts: 3113
Joined: Tue Dec 03, 2019 1:49 pm
Location: holland
Has thanked: 378 times
Been thanked: 1329 times
Contact:

Re: Python3: Simple HTTP Server

Post by fredx181 »

If the simple-python3-http-server .pet is installed:
To create a startup script for SimpleHTTP with upload:

Code: Select all

#!/bin/sh
cd /mnt/home    # shared folder, change as preferred
uploadserver.py  8000   # or change portnumber instead of 8000

And add the script to /root/Startup .

User avatar
Jasper
Posts: 2097
Joined: Wed Sep 07, 2022 1:20 pm
Has thanked: 858 times
Been thanked: 490 times

Re: Python3: Simple HTTP Server

Post by Jasper »

Agggh.....have to wait till tomorrow!!

I am looking forward to this.....especially for my mobile phone.

Thanks @fredx181

User avatar
fredx181
Posts: 3113
Joined: Tue Dec 03, 2019 1:49 pm
Location: holland
Has thanked: 378 times
Been thanked: 1329 times
Contact:

Re: Python3: Simple HTTP Server

Post by fredx181 »

Jasper wrote: Thu May 18, 2023 7:20 pm

Agggh.....have to wait till tomorrow!!

I am looking forward to this.....especially for my mobile phone.

Thanks @fredx181

Just saying...
I tried once serving my external ip-address (with port 80) with SimpleHTTP and it worked OK (from outside local), I could even play the shared music files with my phone.
But I'd say... NOT recommended, it's not really secure, best to use only at your local LAN.

User avatar
Jasper
Posts: 2097
Joined: Wed Sep 07, 2022 1:20 pm
Has thanked: 858 times
Been thanked: 490 times

Re: Python3: Simple HTTP Server

Post by Jasper »

@fredx181

Thanks for this, yes I had only planned this for internal use mainly for access for tablets/phones around the home :thumbup:

Post Reply

Return to “Filesystem”