PythonAnywhere Client
This is a Python client library for interacting with the PythonAnywhere platform. The library provides functions to manage web applications, tasks, and other features offered by PythonAnywhere. It uses the requests library for making HTTP requests and provides a simple interface to perform various tasks.
Installation
You can install it using pip
pip install pythonanywhere-client
Usage
PythonAnywhereWeb
from pythonanywhere_client import PythonAnywhereWeb
# Replace with your PythonAnywhere username and password
username = 'your_username'
password = 'your_password'
# Replace with your User-Agent
user_agent_string = 'my_user_agent_string'
# Create client and request session
client = PythonAnywhereWeb(username, password)
client.create_session(user_agent_string)
# Logging in
login_response = client.login()
if login_response.error:
print('Login failed:', login_response.data['message'])
else:
print('Login successful!')
# Get web application expiry date
app_name = 'your_app_name'
expiry_response = client.get_app_expiry_date(app_name)
if expiry_response.error:
print('Error:', expiry_response.data['message'])
else:
print('Expiry Date:', expiry_response.data['expiry_date'])
# ... (other methods)
PythonAnywhereApi
from pythonanywhere_client import PythonAnywhereApi
# Replace with your API token
token = 'my_api_token'
# Replace with your User-Agent
user_agent_string = 'my_user_agent_string'
client = PythonAnywhereApi(token)
client.create_session(user_agent_string)
file_response = client.get_file('/home/myusername/test.txt')
if file_response.error:
print('Error: ', file_response.data['message'])
else:
print('File content: ', file_response.data['content'])
# ... (other methods)
Methods
PythonAnywhereWeb
login()- Log in to the PythonAnywhere platformlogout()- Log out from the PythonAnywhere platformget_app_expiry_date(app_name)- Get the expiry date of a web applicationreload_app(app_name)- Reload a web applicationextend_task(task_id)- Extend the schedule of a taskextend_app(app_name)- Extend the schedule of a web applicationstart_console(console_id)- Start a console
PythonAnywhereApi
create_console()- Create a consoledelete_console(console_id)- Delete a consolelist_consoles()- List active consolesconsole_latest_output(console_id)- Get the latest output from the consoleconsole_input(console_id, input_string)- Send the input to the consoleget_file(path)- Get the contents of the filecreate_file(path, content)- Create a filedelete_file(path)- Delete a filecan_create_tasks()- Check if the user is allowed to create taskscreate_task(command, description, hour, minute, enabled=True, interval='daily')- Create a taskdelete_task(task_id)- Delete a taskget_tasks(): Get a list of user's tasks.reload_app(app_name)- Reload a web applicationenable_app(app_name)- Enable a web applicationdisable_app(app_name)- Disable a web applicationget_static_headers(app_name)- List static headers for an applicationcreate_static_header(app_name: str, header_url: str, name: str, value: str)- Create a static headerdelete_static_header(app_name: str, header_id: int)- Delete a static headerget_static_header(app_name: str, header_id: int)- Show a static headerget_static_paths(app_name)- List static paths for an applicationcreate_static_path(app_name: str, static_path_url: str, path: str)- Create a static pathdelete_static_path(app_name: str, static_path_id: int)- Delete a static pathget_static_path(app_name: str, static_path_id: int)- Show a static path
Contributing
Contributions to this project are welcome! If you find any issues or have suggestions for improvements, feel free to open an issue or submit a pull request.
Release files for pythonanywhere-client 1.1.6
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| pythonanywhere-client-1.1.6.tar.gz | 9.6 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pythonanywhere_client-1.1.6-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 16.6 kB
Release files / pythonanywhere-client-1.1.6.tar.gz
| Download URL | pythonanywhere-client-1.1.6.tar.gz |
|---|---|
| Size | 9.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
15af5b8fbdd3b34f0572c676863da4511aba4d839b391b24eec5981a478bbcb9
|
|
BLAKE2b-256 checksum How to use checksums |
88a515bb22d22891cf359893dc628bce57d5ade0b4b2dd3260869ea4a0453896
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.5
|
Release files / pythonanywhere_client-1.1.6-py3-none-any.whl
| Download URL | pythonanywhere_client-1.1.6-py3-none-any.whl |
|---|---|
| Size | 7.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a02439fc54974889061b6f924d52560b2bc684309dcd5f2ab1dba83d14c5d00b
|
|
BLAKE2b-256 checksum How to use checksums |
98385ba6cb9d53960550140d6a482bb5c84f6884cc9953c5bffe9180768bea5d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.5
|