Advanced Program
We will write a program that retrieves aggregates from a user.
The aleph-client library is pre-installed and pre-configured in the official Aleph-VM Python runtime. It is tweaked to work even for programs with the access to internet disabled.
1 - Requirements
You need to install aleph-client for local testing.
We will use Uvicorn for local testing and FastAPI to build our program.
Linux/ macOs :
2 - Writing the program
To create the first program, open your favorite code editor and create a directory named my-program
, containing a file named main.py
.
Then write the following code in the file:
That's it for your first program.
This code comes from the FastAPI tutorial. Have a look at it for a better understanding of what it does and how it works.
3 - Testing locally
Before uploading your program on Aleph, it is best to first test it locally.
Aleph uses the standard ASGI interface to interface with programs written in Python. ASGI interfaces with many Python frameworks, including FastAPI but also Django or Quart.
Test your program locally using uvicorn, an ASGI server:
go to your working repository and launch:
Then open http://127.0.0.1:8000 . The --reload
option will automatically reload your app when the code changes.
4 - Deploy
See the publish method.
Last updated