Forum Archive

Is REQUESTS the right approach for what I'm trying to do?

nasadave

Before I go too far down the learning curve, I am wondering if requests is the right module to do what I'm trying to do.

I'd like to pass a file (initially a text file, eventually a photo with metadata) generated thru Pythonista on iPad to a file server on a Linux machine. Is requests the right approach? And are there any examples of doing what I'm trying to do that might be out there?

I have the file creation software up and running but I don't have anything that I can do with it just yet.

Thanks!

ccc

Request is for interacting with an HTML webserver. A file server is a different beast than a web server.

SpotlightKid

If you have a user account on the Linux server and it is running a SSH service (which it probably is), SFTP ist the protocol you're looking for. Pythonista comes with the paramiko module, which has support for SFTP.

The paramiko repository has an example script for uploading files via SFTP:

https://github.com/paramiko/paramiko/blob/master/demos/demo_sftp.py

peterh86

I wouldn't try to write this from scratch, I'd Google for similar code and change it to suit. There is a Python FTP client for Editorial at:

http://editorial-app.appspot.com/workflow/6072079405285376/DrV2vx1eiJQ

though you might find it hard to see the code if you don't have Editorial.

SpotlightKid

Don't use FTP. It's insecure.

nasadave

Ok, so I suppose I have the option of running the Linux server as a file server or an HTML server since I'll be controlling the host. That being said, would you still recommend against requests? Another approach? Basically I want to use the iPad to create a file, pass it to the Linux, and have a different program on the Linux manipulate the file.

ccc

I like the paramiko --> SFTP approach that SpotlightKid recommended. Another alternative could be Dropbox.

nasadave

I'll look into both.