Skip to main content

PythonAnywhere API wrapper.

Project description

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

History

UNRELEASED

0.3.1 (2020-12-19)

  • fixes PyPi upload error, Issue #6

0.3.0 (2020-12-19)

  • drop support for python 2, add 3.7, 3.8, and 3.9.

0.2.0 (2017-10-21)

  • name change from pythonanywhere to pythonanywhere-wrapper

  • Add history

0.1.1

  • Add attribution for chargify-python

0.1.0

  • Initial release on PyPI

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pythonanywhere-wrapper-0.3.1.tar.gz (6.1 kB view details)

Uploaded Source

Built Distribution

pythonanywhere_wrapper-0.3.1-py3-none-any.whl (8.5 kB view details)

Uploaded Python 3

File details

Details for the file pythonanywhere-wrapper-0.3.1.tar.gz.

File metadata

  • Download URL: pythonanywhere-wrapper-0.3.1.tar.gz
  • Upload date:
  • Size: 6.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.1 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.8.5

File hashes

Hashes for pythonanywhere-wrapper-0.3.1.tar.gz
Algorithm Hash digest
SHA256 e274a538579695ebdb4dc4b6c5067f5ce74bec667d13b833fa9d509a4e90e0d8
MD5 365aeeb2ecd65c3c7bb8db3ef195fc8d
BLAKE2b-256 35a4c8c6369caa93b23c225620b0e8047ec11fd7d8b1b174b5e83ee6526ea966

See more details on using hashes here.

File details

Details for the file pythonanywhere_wrapper-0.3.1-py3-none-any.whl.

File metadata

  • Download URL: pythonanywhere_wrapper-0.3.1-py3-none-any.whl
  • Upload date:
  • Size: 8.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.1 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.8.5

File hashes

Hashes for pythonanywhere_wrapper-0.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 e40332a991e484b7803d153bc26abc0879f0adc72f09ed40bc2a552d2585de69
MD5 361d871a36b894b54bacdca0d0c37da0
BLAKE2b-256 35d0dedd2285dbb67c0315319873a953afeb556f1072bc5866b217155c9c74a2

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page