|
| 1 | +Welcome to pythonanywhere-core |
| 2 | +================================ |
| 3 | + |
1 | 4 | API wrapper for programmatic management of PythonAnywhere services. |
2 | 5 |
|
3 | | -It's an extraction and improvement of core code behind `PythonAnywhere cli tool`_. |
| 6 | +``pythonanywhere-core`` provides a Python interface for managing webapps, files, scheduled tasks, |
| 7 | +students, and websites via the PythonAnywhere API. It serves as the core library behind the |
| 8 | +`PythonAnywhere CLI tool`_ and `PythonAnywhere MCP server`_. |
| 9 | + |
| 10 | +.. _PythonAnywhere CLI tool: https://pypi.org/project/pythonanywhere/ |
| 11 | +.. _PythonAnywhere MCP server: https://pypi.org/project/pythonanywhere-mcp-server/ |
| 12 | + |
| 13 | +Quick Start |
| 14 | +----------- |
| 15 | + |
| 16 | +Install the library: |
| 17 | + |
| 18 | +.. code-block:: bash |
| 19 | +
|
| 20 | + pip install pythonanywhere-core |
| 21 | +
|
| 22 | +Set up your API token (if running outside PythonAnywhere): |
| 23 | + |
| 24 | +.. code-block:: bash |
| 25 | +
|
| 26 | + export API_TOKEN="your_token_from_pythonanywhere_account_page" |
| 27 | +
|
| 28 | +.. note:: |
| 29 | + **Creating your API token:** Go to the "Account" page on PythonAnywhere, then to the |
| 30 | + "API Token" tab, and click "Create a new API token". |
| 31 | + |
| 32 | + If you're running code on PythonAnywhere itself, the token is automatically available. |
| 33 | + You only need to set ``API_TOKEN`` when running locally or from external servers. |
| 34 | + |
| 35 | + See :doc:`reference/environment-variables` for more details on configuration. |
| 36 | + |
| 37 | +Create your first webapp: |
| 38 | + |
| 39 | +.. code-block:: python |
| 40 | +
|
| 41 | + from pythonanywhere_core.webapp import Webapp |
| 42 | + from pathlib import Path |
| 43 | +
|
| 44 | + webapp = Webapp("yourusername.pythonanywhere.com") |
| 45 | + webapp.create( |
| 46 | + python_version="3.12", |
| 47 | + virtualenv_path=Path("/home/yourusername/.virtualenvs/myenv"), |
| 48 | + project_path=Path("/home/yourusername/myproject"), |
| 49 | + nuke=False |
| 50 | + ) |
| 51 | + webapp.reload() |
4 | 52 |
|
5 | | -.. _PythonAnywhere cli tool: https://pypi.org/project/pythonanywhere/ |
| 53 | +Documentation |
| 54 | +------------- |
6 | 55 |
|
| 56 | +📖 **Reference Documentation** |
| 57 | + Complete technical specifications for all modules, classes, and functions. |
| 58 | + |
| 59 | + :doc:`Go to Reference → <reference/index>` |
| 60 | + |
| 61 | + - :doc:`reference/environment-variables` - Configuration via environment variables |
| 62 | + - :doc:`reference/python-versions` - Supported Python versions |
| 63 | + - :doc:`reference/exceptions` - Exception types and error handling |
| 64 | + - :doc:`API Reference <reference/api/index>` - Complete API reference |
| 65 | + |
| 66 | +Installation |
| 67 | +------------ |
| 68 | + |
| 69 | +Install via pip: |
| 70 | + |
| 71 | +.. code-block:: bash |
| 72 | +
|
| 73 | + pip install pythonanywhere-core |
| 74 | +
|
| 75 | +For development: |
| 76 | + |
| 77 | +.. code-block:: bash |
| 78 | +
|
| 79 | + git clone https://github.com/pythonanywhere/pythonanywhere-core.git |
| 80 | + cd pythonanywhere-core |
| 81 | + poetry install |
| 82 | +
|
| 83 | +See :doc:`installation` for more details. |
| 84 | + |
| 85 | +Features |
| 86 | +-------- |
| 87 | + |
| 88 | +- **Webapp Management**: Create, configure, reload, and delete WSGI web applications (Django, Flask, etc.) |
| 89 | +- **Website Management**: Handle domains and website configuration for ASGI and other apps (FastAPI, Streamlit, etc.) |
| 90 | +- **File Operations**: Upload, download, delete, and share files |
| 91 | +- **SSL Configuration**: Set up and manage SSL certificates |
| 92 | +- **Scheduled Tasks**: Create and manage scheduled tasks |
| 93 | +- **Student Management**: Manage student accounts (for teachers) |
| 94 | + |
| 95 | +Links |
| 96 | +----- |
| 97 | + |
| 98 | +- **GitHub Repository**: https://github.com/pythonanywhere/pythonanywhere-core |
| 99 | +- **PyPI Package**: https://pypi.org/project/pythonanywhere-core/ |
| 100 | +- **PythonAnywhere API Docs**: https://help.pythonanywhere.com/pages/API/ |
| 101 | +- **Issue Tracker**: https://github.com/pythonanywhere/pythonanywhere-core/issues |
| 102 | + |
| 103 | +Table of Contents |
| 104 | +----------------- |
7 | 105 |
|
8 | 106 | .. toctree:: |
9 | 107 | :maxdepth: 2 |
10 | | - :caption: Contents: |
11 | | - |
| 108 | + :caption: Documentation: |
12 | 109 |
|
13 | 110 | installation |
14 | | - api/index |
| 111 | + reference/index |
15 | 112 |
|
16 | | -Indices and tables |
| 113 | +Indices and Tables |
17 | 114 | ================== |
18 | 115 |
|
19 | 116 | * :ref:`genindex` |
20 | 117 | * :ref:`modindex` |
| 118 | +* :ref:`search` |
0 commit comments