Reference Documentation
Complete technical reference for the pythonanywhere-core API.
Configuration & Core Concepts
API Reference
Common Tasks
Reloading a Webapp
from pythonanywhere_core.webapp import Webapp
webapp = Webapp("myuser.pythonanywhere.com")
webapp.reload()
See Web Apps for complete webapp management API.
Uploading a File
from pythonanywhere_core.files import Files
files = Files()
with open("local_file.txt", "rb") as f:
files.path_post("/home/myuser/remote_file.txt", f.read())
See Files for complete file operations API.
Creating a Scheduled Task
from pythonanywhere_core.schedule import Schedule
schedule = Schedule(username="myuser")
task = schedule.create(
command="python /home/myuser/myscript.py",
enabled=True,
interval="daily",
hour=3,
minute=0
)
See Scheduled Tasks for complete scheduled task API.
Error Handling
from pythonanywhere_core.exceptions import (
NoTokenError,
AuthenticationError,
PythonAnywhereApiException
)
try:
webapp.reload()
except NoTokenError:
print("Set API_TOKEN environment variable")
except AuthenticationError:
print("Invalid API token")
except PythonAnywhereApiException as e:
print(f"API error: {e}")
See Exceptions for complete exception reference.