Package: pythonanywhere-client
PythonAnywhere ClientThis 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.InstallationYou can install it using pippipinstallpythonanywhere-clientUsagePythonAnywhereWebfrompythonanywhere_clientimportPythonAnywhereWeb# Replace with your PythonAnywhere username and passwordusername='your_username'password='your_password'# Replace with your User-Agentuser_agent_string='my_user_agent_string'# Create client and request sessionclient=PythonAnywhereWeb(username,password)client.create_session(user_agent_string)# Logging inlogin_response=client.login()iflogin_response.error:print('Login failed:',login_response.data['message'])else:print('Login successful!')# Get web application expiry dateapp_name='your_app_name'expiry_response=client.get_app_expiry_date(app_name)ifexpiry_response.error:print('Error:',expiry_response.data['message'])else:print('Expiry Date:',expiry_response.data['expiry_date'])# ... (other methods)PythonAnywhereApifrompythonanywhere_clientimportPythonAnywhereApi# Replace with your API tokentoken='my_api_token'# Replace with your User-Agentuser_agent_string='my_user_agent_string'client=PythonAnywhereApi(token)client.create_session(user_agent_string)file_response=client.get_file('/home/myusername/test.txt')iffile_response.error:print('Error: ',file_response.data['message'])else:print('File content: ',file_response.data['content'])# ... (other methods)MethodsPythonAnywhereWeblogin()- 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 consolePythonAnywhereApicreate_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 pathContributingContributions 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.