Skip to main content

Thin wrapper for the PythonAnywhere API.

Project description

pythonanywhereapiclient

Pipeline Coverage PyPI

Thin wrapper for the PythonAnywhere API.

Features

  • Basic API client responsible for authentication and sending requests
  • List and configure webapps
  • List and upload files

Technical requirements

Below is the list of currently supported Python releases:

# Python
1 3.6
2 3.7
3 3.8

Code and contribution

The code is open source and released under the MIT License (MIT). It is available on Gitlab and follows the guidelines about Semantic Versioning for transparency within the release cycle and backward compatibility whenever possible.

All contributions are welcome, whether bug reports, code contributions and reviews, documentation or feature requests.

Getting Started

This document provides all the basic information you need to start using the client. It covers base concepts, shows examples, and documents links for further reading.

Setup

There are a few setup steps you need to complete before you can proceed:

  1. Sign up for a PythonAnywhere account, if you don't already have one.
  2. Activate your personal API token.

Installation

Install pythonanywhereapiclient using pip:

pip install pythonanywhereapiclient

Configuration

The client simply needs three environment variables to work properly:

  • PYTHONANYWHERE_API_CLIENT_HOST
  • PYTHONANYWHERE_API_CLIENT_TOKEN
  • PYTHONANYWHERE_API_CLIENT_USER

For example to set these environment variables in a bash:

export PYTHONANYWHERE_API_CLIENT_HOST="www.pythonanywhere.com"
export PYTHONANYWHERE_API_CLIENT_TOKEN="yoursecrettoken"
export PYTHONANYWHERE_API_CLIENT_HOST="yourusername"

Valid values for PYTHONANYWHERE_API_CLIENT_HOST are www.pythonanywhere.com and eu.pythonanywhere.com.

Usage

The following examples showcase some typical usage scenarios.

from pythonanywhereapiclient import file, webapp

# List all webapps
webapp.list()

# Create a webapp
webapp.create('example.com', 'python36')

# Modify an existing webapp
webapp.modify(
    'example.com',
    python_version='3.6',
    working_directory='/home/user/work',
    source_directory='/home/user/source',
    virtualenv_path='/home/user/virtualenv',
    force_https=True
)

# Create a static mapping
webapp.create_static('example.com', '/static/', '/home/user/data/static')

# Reload a webapp (e.g. after source or configuration changes)
webapp.reload('example.com')

# Disable a webapp
webapp.disable('example.com')

# Enable a webapp
webapp.enable('example.com')

# Delete a webapp
webapp.delete('example.com')

# List all files at path
file.list('/home/username/data')

# Upload a file
file.upload('/home/username/data/foo.txt', 'this is a text file')

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

pythonanywhereapiclient-1.0.1-py3-none-any.whl (6.9 kB view details)

Uploaded Python 3

File details

Details for the file pythonanywhereapiclient-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: pythonanywhereapiclient-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 6.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.8.2

File hashes

Hashes for pythonanywhereapiclient-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ab32f17d6b45bb01a66d58f8d72bd8671e07f8aa29950cbd9bbdd61c2cff89e3
MD5 95ff1689bf3e204e908a5ea3fb65cd55
BLAKE2b-256 0b3fc933a19dd7cdd3a124898fb66708344f3d815c8204ba9e4e088185352486

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