8

Just made a http server handling only file uploading. Want to add a feature to the http server sharing the file on Get request by a http client.

I have no idea how to show the file to clients. So a client can see it using http://127.0.0.1/filename.avi

In summary

A http client is uploading a file to a http server.

A http client is watching the file through the http server

4 Answers 4

16

Python 2: SimpleHTTPServer.

python2 -m SimpleHTTPServer 80

Python 3: http.server.

python -m http.server 80

Sign up to request clarification or add additional context in comments.

3 Comments

Should have told that I used HTTPServer and BaseHTTPRequest classes in my project. So want to keep them as it is and add the feature.
If you already implemented an http server that supports POST, then it should be trivial to implement get, check SimpleHTTPServer's code. check : /usr/lib/python2.6/SimpleHTTPServer.py
@user518978 if you can upload a file you are almost there. Your server will need to keep track of the uploaded files somehow (presumably you are saving these files somewhere on the filesystem). You could implement a method that when the client requests the root ("GET /") you return a list of files. Then the client can request the particular file you want to stream to it.
3

for the local server with python I run

$ python3 -m http.server 8080

inside the folder that contains my index.html. Is there any way (maybe a specific flag) to proxy the requests which can't be resolved locally to a given url?

Comments

0

You can look at Flask. It is very lightweight and probably does most of what you're looking for.

Comments

0

new python would be python -m http.server [port number] in the command prompt

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.