I would like to have a simple web page on which user can upload files. What would be the simplest way to do it.
I know how to start SimpleHTTPServer
but I do not know how I can upload files using SimpleHTTPServer
. I do not even know if it is possible.
I found some code for uploading files using cgi but if I execute this code in the command line it just prints me HTML code on the screen.
Yes, SimpleHTTPServer can receive http uploads with the correct request handler.
Basicly you need to define a do_POST method where a form or something similar uploads the data. the upload is then readble from self.rfile.
of course if you want to upload from a browser you need to have a form somewhere that posts to the http server:
More details in particular how to parse the raw data from the form-data can be found in the links posted as comments to the question.