Basic Program
We will write a basic Python program to send over an Aleph Program Message.
1 - Requirements
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