:: Re: [DNG] Web server [Dng Digest, V…
Pàgina inicial
Delete this message
Reply to this message
Autor: R A Montante, Ph.D.
Data:  
A: dng
Assumpte: Re: [DNG] Web server [Dng Digest, Vol 121, Issue 25 ]
Python has a basic web server, if that's of interest.  Could be a
starting point, at least.

From the online help:

> help(http.server.HTTPServer)
> Help on class HTTPServer in module http.server:


-Bob

On 10/7/24 12:42, dng-request@??? wrote:
> Message: 1
> Date: Mon, 7 Oct 2024 15:58:17 +0200
> From: Didier Kryn<kryn@???>
> To:dng@???
> Subject: [DNG] Web server [ was Re: Learning C (books) ]
> Message-ID:<bf8e9a7c-23a1-49bc-b58f-8052eaf6f0fe@???>
> Content-Type: text/plain; charset=UTF-8; format=flowed
>
> Le 07/10/2024 ? 12:57, Nick via Dng a ?crit?:
>> Just curiosity but what is so special that you are writing a complete
>> new web server for it?
> ??? My initial goal was to upload files from my smartphone (I bought my
> 1st one 1 year ago) to my laptop. You know that smartphones are
> producers of images files. I do not like extracting and inserting the SD
> card: it is delicate and likely to break something. Note also that I
> have experimented trying to move a video file from a USB stick to the
> Windows computer of a friend, and the Windows, after half an hour, was
> still not responsive, and when we gave up and removed the USB stick, I
> discovered Windows had written hundreds of junk files into it.
>
> ??? It appeared to me that the HTTP protocol was the solution, because
> there are plethora of functionnal browsers both on Windows and on
> smartphones and they are forced to comply to the protocol and this
> protocol provides a good insulation of both ends. Furthermore,
> smartphones provide fast wifi connections when you enable connection
> sharing and connect you computer to it
>
> ??? I did not want either to write a cgi-bin program and configure a
> full featured NGINX server to upload files through this cgi-bin because
> it needs a complicated configuration. I wanted a lightweight solution.
> Therefore I decided to write a web server which provides upload out of
> the box and does not need any configuration. I first hacked a server
> which provided upload. It took me one month.
>
> ??? My server works on one single directory and follows neither subdirs
> nor symbolic links; it is a one-client server, and it needs absolutely
> no configuration.? But it was difficult to use, let me explain why.
>
> ??? To permit upload, the client sends a GET request to which the
> server replies by sending an HTML form with the method POST and the
> Content-Type multipart/form-data. To perform file-selection and
> submission, the browsers implement their own selectors and buttons, and
> they are almost unreadable, at least on smartphones. Industrial web
> services get around this by using javascripts. I don't know javascript
> and don't want; therefore I had to work out style shits.
>
> ??? Two other issues arised: first my HTTP parser was really a hack and
> I wanted to make it more robust. I devised a method based on Flex which
> I find now unmaintainable and I am working to change again. Second, on
> smartphones, you cannot click on the right mouse button to download a
> file instead of display it, therefore I implemented special links for
> download. Third, while I was on this way, I implemented the delete
> functionality. My server can now visit, download, upload and delete.
> Upload and delete can be done several files in one shot, but there is no
> way in HTML to download several files.
>
> ??? My server presents 3 pages, each containing buttons to reach the
> two others, plus an exit button. The visit/download page is a particular
> format of autoindex and the delete page is another format of autoindex.
> The upload page contains the browser's file-selector and the erase and
> submit buttons. The download/visit page and the delete page are
> obviously generated dynamically.
>
> ??? My current work is to replace the Flex-based parser with a bare C
> one. Then I will add some limited internationalization, since I intend
> to make this work public. The internationalization will be for the error
> pages sent to the client, based on the Accept-Language header line sent
> by the browser. The server side will still write log and error messages
> in the Unix jargon.
>
> ??? The usage is extremely simple: you execute the server in a terminal
> emulator, with a path as argument. The last directory in the path is
> then shared with the first client which connects.
>
> ??? -- ??? Didier
>
>

--
R A Montante, Ph.D.
Department of Mathematics, Computer Science, and Digital Forensics
Commonwealth University - Bloomsburg University campus
--
The Tao of math: The numbers you can count are not the real numbers.