FastAPI Quick-Start
This quick-start will guide you through packaging your python app with FastAPI and deploying it to Health Universe, the open-source health research cloud for ML/AI.
Step 1: Create a GitHub repository
Create a new repository on GitHub to host your project. You can make the repository either public or private, and it is a good idea to have a readme.md file in the repository and use a .gitignore template so that you can ignore the .env. This is important when you're linking a local development environment to a github repository.
Note: If you're using a local development environment, link your local environment to your GitHub repository
Clone the repository to your local machine or use our FastAPI Template:
git clone https://github.com/<your_account>/<your_repo_name>.gitChange to your project directory:
cd <your_repo>Create a virtual environment using:
python -m venv .envActivate your virtual environment with:
source .env/bin/activateUpgrade pip to make sure things go smoothly:
python -m pip install --upgrade pipInstall the FastAPI, Uvicorn, & Pydantic libraries with:
pip install fastapi uvicorn pydantic
Step 2: Create your python app
In your local repository, create the following files:
main.py: This file should contain your Python model.
requirements.txt: This file will list your project dependencies.
Next, learn a little bit about how FastAPI works.
Overview of the main concepts for creating UI with FastAPI.
Here's a nifty cheat sheet for all the parameters you can create.
main.py
For FastAPI apps, it is best to work from a template so that Navigator knowns how to interact with your app. The template is listed below:
requirements.txt
For FastAPI apps, at a minimum you should include the requirements listed below. You may have additional requirements specific to your app, so be sure to include those as well.
Test out your app by running it locally:
Run your app locally using:
uvicorn main:app --reloadUse the auto-generated Swagger UI at: http://127.0.0.1:8000/docs
Step 3: Deploy to Health Universe
Push your local repo to GitHub.
Log in or create a Health Universe account if you haven't already.
Go to https://healthuniverse.com and navigate to "Apps."
Click "Add App" to create a new app.
Fill out the following fields:
App Name: Name of your app
Description: A brief description of your app
Github Account: Your GitHub username
Github Repo: The exact name of your GitHub repository
Main File: The name of your python file (usually
main.py)
Click "Add App" to deploy your app. This process may take a few minutes.
Once you've completed these steps, your app will be published on Health Universe!
Last updated
Was this helpful?