Skip to main content

An API wrapper around the PythonAnywhere's API.

Project description

image

made-with-python License: MIT PyPI version Code Size


Overview

An API wrapper around the PythonAnywhere's API. The name stands for pythonanywherewrapper. The key-features are,

  • Modern API wrapper using the async / await syntax
  • 100% API coverage, 100% tested
  • Object-oriented
  • Fully documented & Typehinted
  • Caching handled

We strive to provide an easy-to-use, batteries included modern API wrapper. The documentation can be found here, for help please open an issue.

Installation

The required Python version for the module is 3.9 or above.

# Linux/MacOS
python3 -m pip install pyaww

# Windows
py -m pip install pyaww

Quick Example

To use this module, you first have to create an API key over here. After you've done that, copy the credentials and provide them to the pyaww.User class. It is advised that you do not make your token public within the code, instead, you should store it securely using a package like python-dotenv.

This module is asynchronous meaning it utilises the async / await syntax.

import pyaww
import asyncio

# construct the user class
client = pyaww.User("sexychad420", "my-python-anywhere-token")

async def cpu() -> dict:
    """Gets the CPU information."""
    return await client.get_cpu_info()

asyncio.run(cpu())

Using this module within PythonAnywhere webapps might be a little tricky as they only support WSGI at the moment. However, you can run the function calls synchronously with asyncio module if your desired web framework doesn't support async syntax. Some back-end frameworks such as flask support async syntax in the routes, example:

from flask import Flask
import pyaww

app = Flask(__name__)
client = pyaww.User("sexychad420", "my-python-anywhere-token")

@app.route("/")
async def cpu_usage():
    return await client.get_cpu_info()

if __name__ == '__main__':
    app.run()

If there is no way that you can use the async/await syntax within your webapp, you can downgrade to >3.0.0 versions of this module.

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

pyaww-1.0.0.tar.gz (14.8 kB view hashes)

Uploaded Source

Built Distribution

pyaww-1.0.0-py3-none-any.whl (18.2 kB view hashes)

Uploaded Python 3

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