Giter Club home page Giter Club logo

pythonanywhere-wrapper's Introduction

pythonanywhere-wrapper

A PythonAnywhere API wrapper.

https://travis-ci.org/cfc603/pythonanywhere-wrapper.png?branch=master https://codecov.io/github/cfc603/pythonanywhere-wrapper/coverage.svg?branch=master

Usage

from pythonanywhere_wrapper.client import PythonAnywhere

# If running on a PythonAnywhere terminal, your token and username will
# be discovered automatically. Be sure to setup your API_TOKEN first.

# For information on setting up your API_TOKEN visit
# http://help.pythonanywhere.com/pages/API
API_TOKEN = "test-token"

# Your PythonAnywhere Username
USER = "test-user"

client = PythonAnywhere(api_key=API_TOKEN, user=USER)

Endpoints

Consoles:

# List all your consoles
response = client.consoles()

# View consoles shared with you
response = client.consoles.shared_with_you()

# Get console by id
response = client.consoles(console_id=123456)

# Kill a console by id
response = client.consoles.delete(console_id=123456)

Files:

# Start sharing a file
response = client.files.sharing.create(data={"path": "/path/to/file"})

# Get sharing status by path
response = client.files.sharing(path="/path/to/file")

# Stop sharing a file
response = client.files.sharing.delete(path="/path/to/file")

# List contents of a directory and subdirectories
response = client.files.tree(path="/path/to/directory")

Webapps:

# List all webapps
response = client.webapps()

# Create a new webapp
response = client.webapps.create(data={
        "domain_name": "username.pythonanywhere.com",
        "python_version": "python27",
    })

# Get webapp by domain name
response = client.webapps(domain_name="username.pythonanywhere.com")

# Modify config of a webapp. Follow with reloading webapp.
response = client.webapps.update(
    domain_name="username.pythonanywhere.com", data={
        "python_version": "3.6",
        "virtualenv_path": "/path/to/virtualenv",
    }
)

# Delete webapp by domain name
response = client.webapps.delete(domain_name="username.pythonanywhere.com")

# Reload webapp
response = client.webapps.reload(domain_name="username.pythonanywhere.com")

Static Files:

# List all static files mappings for a domain
response = client.webapps.static_files(
    domain_name="username.pythonanywhere.com"
)

# Create a new static file mapping for a domain. Reload webapp required.
response = client.webapps.static_files.create(
    domain_name="username.pythonanywhere.com", data={
        "url": "/static/", "path": "/path/to/static/dir"
    }
)

# Get static file mapping by id
response = client.webapps.static_files(
    domain_name="username.pythonanywhere.com", static_id=123
)

# Modify a static file mapping. Reload webapp required.
response = client.webapps.static_files.update(
    domain_name="username.pythonanywhere.com", static_id=123, data={
        "url": "/static/", "path": "/path/to/static/dir"
    }
)

# Delete a static file mapping by id. Reload webapp required.
response = client.webapps.static_files.delete(
    domain_name="username.pythonanywhere.com", static_id=123
)

Credit

This application uses Open Source components. You can find the source code of their open source projects along with license information below. We acknowledge and are grateful to these developers for their contributions to open source.

Project:chargify-python https://github.com/stevenwei/chargify-python
Copyright:Copyright (c) 2010 Hindsight Labs
License:(MIT) https://github.com/stevenwei/chargify-python/blob/master/LICENSE

pythonanywhere-wrapper's People

Contributors

cfc603 avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

pythonanywhere-wrapper's Issues

PyPi HTTPError: 400 Bad Request

When uploading the latest version to PyPi Test, get the following error:

HTTPError: 400 Bad Request from https://test.pypi.org/legacy/ The description failed to render in the default format of reStructuredText. See https://test.pypi.org/help/#description-content-type for more information.

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.