Python Forum

Full Version: How can I upload some files to my website?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello guys,

I'm currently saving some .csv files on my computer, but I would like to upload those .csv files to my website, is it possible to be done using Python?
How do you normally upload stuff to your site? If you use FTP, for example, Python certainly has an FTP client in the standard library.
(Mar-17-2021, 01:24 PM)ndc85430 Wrote: [ -> ]How do you normally upload stuff to your site? If you use FTP, for example, Python certainly has an FTP client in the standard library.

Yes, I normally do it using FTP.
let me try!
You can use Requests for this.
A couple of examples.
import requests

response = requests.put('http://ftp://username:[email protected]/backup/')
import requests

headers = {'Content-Type': 'multipart/form-data',}
files = {
    'data': ('test.mp3', open('test.mp3', 'rb')),
}
response = requests.post('http://mysuperserver/media/upload/', headers=headers, files=files)