Page 1 of 1

Simple Python3 http-server

Posted: Tue Jan 24, 2023 2:40 pm
by fredx181

*** Simple Python3 http-server xbps package ***

UPDATE: new attached package: v1.1_0, fixed that setting port number to other than 8000 didn't work in case of "upload enabled".

Originally made by @rcrsn51 (gtkdialog GUI and working with python2), I modified for KLV, to make it work with python3.
"Simple file-sharing system for your home LAN. It uses Python to run a basic HTTP server."
See: https://oldforum.puppylinux.com/viewtop ... 095#979095

Run the GUI (Menu > Internet > Simple Python HTTP server),
or: run directly with python3 in terminal (from standing in the directory to share):
python3 -m http.server 8000 # or any port instead of 8000, e.g. 80
Or with upload enabled:
python3 -m SimpleHTTPServerWithUpload 8000

The SimpleHTTPServerWithUpload.py script included in the package, I got from here: (edit replaced link, this fork works for setting port number)
https://gist.github.com/PerfectDay20/df ... 5c0ce68827

I think it's a nice simple way of local network sharing, downside is that you need a browser to access your files e.g. in adress bar 192.168.1.2:8000 or e.g. 192.168.1.2:80
Btw, (last time that I tried it worked) instead you can use also your external IP address, then e.g. <ext-ip-address>:80 (then access your files outside home LAN, so for everyone).

simple-python-http-server-1.1_0.noarch.xbps
Simple python3 http-server package
(8.28 KiB) Downloaded 49 times
Screenshot.png
Screenshot.png (149.38 KiB) Viewed 1011 times

Re: Simple Python3 http-server

Posted: Wed Jan 25, 2023 10:04 am
by wiak

I should try this. I'm always needing something light to move files around without having to plug in usb sticks and moving them around (which gets me off my computer seat, but is an annoying distraction).

I only just noticed this post. I do not use any notification of new posts sort of system so rely on what I browse; actually I don't know how to arrange to follow thread posts. I'm bad for not learing useful tricks like that (assuming there are some).

The other rcrsn51 creation I kept meaning to try was his method of sending audio/video across the network. Pulseaudio never proved very good at that because of the tcp protocol it uses, whereas I recall rcrsn51 using a simple comms program (presumable using udp) such that little latency and good sync. trx or somename like that for part of it?


Re: Simple Python3 http-server

Posted: Wed Jan 25, 2023 11:18 am
by Sofiya

Super! Works great :thumbup2:


Re: Simple Python3 http-server

Posted: Wed Jan 25, 2023 11:59 am
by rockedge

Great to work with!

Sort of like using the builtin Hiawatha web server in Puppy Linux to serve files across a LAN or WLAN and could be reached externally easily if setup to allow it.
I should examine more how audio is served.......

One question though, I can't seem to be able to set the port to anything other than 8000 :?


Re: Simple Python3 http-server

Posted: Wed Jan 25, 2023 4:28 pm
by fredx181
rockedge wrote: Wed Jan 25, 2023 11:59 am

....
One question though, I can't seem to be able to set the port to anything other than 8000 :?

Ah, yes, I see now, problem is only when upload is enabled though.
Found a fork of the python script SimpleHTTPServerWithUpload.py that works OK for setting port number: https://gist.github.com/PerfectDay20/df ... 5c0ce68827
New package attached at first post with fix (v1.1_0)

Btw, just a tip, if you want the server started at boot, just add a simple script to ~/Startup with contents e.g:

Code: Select all

#!/bin/bash
cd /path/to/share-folder    # change this to the folder you wish to share
python3 -m SimpleHTTPServerWithUpload 8000   # or change port number (v1.1_0 only)


Re: Simple Python3 http-server

Posted: Thu May 18, 2023 8:42 pm
by fredx181

Updated Simple Python3 http-server xbps package, it has 'uploadserver' included which supports multiple file upload and uploading through commandline using curl.
See also: viewtopic.php?p=89393#p89393

simple-python-http-server-1.2_0.noarch.xbps
(11.37 KiB) Downloaded 39 times

-----------------------------------------------------------------------------------------------------------------------------
And simple-http-filemanager, supports upload and download to/from SimpleHTTP server

simple-http-filemanager-1.1_0.noarch.xbps
(9.49 KiB) Downloaded 45 times

Also, as extra, many 'index' http(s) sites supported for downloading.
Including https://rockedge.org, no browser needed to download latest KLV :) :

Screenshot(1).png
Screenshot(1).png (97.27 KiB) Viewed 757 times