Code Monkey home page Code Monkey logo

pythonista-fileserver's Introduction

Pythonista File Server

Based on omz/FileTransfer.py. Get Pythonista for iOS here: Pythonista.

This script attempts to make transferring files to and from Pythonista a little bit more secure by using SSL, and Basic authentication.

Use at your own risk...

Setup

You will need an SSL self signed certificate before you start. There are a bunch of posts on the web on how to do this already. Just looks around. :-)

  1. Get this script PythonistaFileServer.py onto your Pythonista installation.
  2. Run PythonistaFileServer.py. This first attempt will fail. Running PythonistaFileServer.py will make the module available in the console, which is needed for the next step.
  3. Go to the Pythonista console and:
    >>> import PythonistaFileServer
    >>> PythonistaFileServer.init_config()
    
    That will create the ~/Documents/.httpfileserver directory, and initialize the config.cfg file in there.
  4. Swipe right to go back to the editor, you should see ~/Documents/.httpfileserver/config.cfg. Make sure to fill in the username, and password.
  5. Upload your server.key, and server.crt files into the ~/Documents/.httpfileserver directory.
  6. Start up PythonistaFileServer. You should be good to go.

Howtos

From within Pythonista

Modify your configuration

  1. From within Pythonista, run PythonistaFileServer, then quit. This will make PythonistaFileServer available for import.
  2. Swipe left to get the console, and
    >>> import PythonistaFileServer
    >>> PythonistaFileServer.edit_config()
    
  3. Swipe right to bring up the editor then make your changes.

Curl

The following examples assumes a username of test, and password of tester. Pick something more secure.

List files in a directory

To the document root:

$ curl --insecure --user "test:tester" "https://testserver.local:8843/"
{
    "cwd": "/",
    "files": [
        "PythonistaFileServer.py",
        "Welcome.txt",
        "test1/Welcome.txt"
    ],
    "status": {
        "message": "success",
        "type": "success"
    }
}

To sub directories:

$ curl --insecure --user "test:tester" "https://testserver.local:8843/test1"
{
    "cwd": "/test1",
    "files": [
        "test1/Welcome.txt"
    ],
    "status": {
        "message": "success",
        "type": "success"
    }
}

Upload a file to a directory

To the document root:

$ curl --insecure --user "test:tester" -F "[email protected]" \
        "https://testserver.local:8843/"
{
    "cwd": "/",
    "files": [
        "PythonistaFileServer.py",
        "somescript.py",
        "Welcome.txt",
        "test1/Welcome.txt"
    ],
    "status": {
        "message": "success",
        "type": "success"
    }
}

To a sub directory:

$ curl --insecure --user "test:tester" -F "[email protected]" \
        "https://testserver.local:8843/test1"

Uploading and excluding the files section, set the short query parameter to true:

$ curl --insecure --user "test:tester" -F "[email protected]" \
        "https://testserver.local:8843/test1?short=true"
{
    "cwd": "/test1",
    "status": {
        "message": "somescript.txt uploaded (renamed to somescript-3.txt).",
        "type": "success"
    }
}

Overwriting a file on upload

Set the overwrite query parameter to true:

$ curl --insecure --user "test:tester" -F "[email protected]" \
        "https://testserver.local:8843/test1?short=true&overwrite=true"

Change log

pythonista-fileserver's People

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.