Typical Project Setup
Last updated
Was this helpful?
Last updated
Was this helpful?
Now that you have installed the required software, it's time to create a basic FastAPI project. In this section, we'll guide you through creating a new project, configuring your development tools, and setting up a basic API structure.
Because FastAPI apps can be more complex (and Health Universe is primarily a deployment, not a development environment), it is best to have a local development environment that is linked to your GitHub repository.
Go to GitHub and create a new public repository. At this time, the repo must be public in order for Health Universe to be able to deploy your project.
Clone Your Repository
git clone https://github.com/<your_account>/<your_repo_name>.git
Use Our Template
Start with our , designed to work seamlessly with the Health Universe Navigator interface. It’s highly recommended, as it’s easy to customize and already optimized for deployment.
Click the green “Use this template” button (top right).
Select “Create a new repository”.
Give your new repository a name (e.g., tool-bmi-calculator
).
Click “Create repository from template”.
Once it's created, clone your new repo to your local machine OR modify the script within Github.
Setting up a virtual environment for your Health Universe projects is required as it creates the requirements.txt file needed to specify your application's dependencies. To create a virtual environment, follow these steps:
Open a terminal and navigate to your desired project directory.
Create a new virtual environment with the following command:
Activate the virtual environment:
Windows:
macOS and Linux:
Once activated, your terminal should display the environment name, e.g., (venv)
.
FastAPI is a high-performance framework for building APIs. Uvicorn is the ASGI server used to run FastAPI apps.. To install them, run the following command in your terminal:
Wait for the installation to complete. FastAPI, Uvicorn, etc is now installed on your system and ready for use in your Health Universe projects.
Let's build a simple "Hello, World!" style API with input validation using Pydantic.
Open main.py
in your editor and add:
Save the main.py
file.
To run your "Hello, World!" FastAPI app, open the terminal, navigate to your project directory, and run the following command:
Then open your browser and go to:
To stop the app, press Ctrl+C
in the terminal.
From your terminal, run:
This command will save all your project's dependencies into a requirements.txt file. This file is read by the Health Universe cloud to know what libraries your app will require.
to view the root endpoint.
to test your API using Swagger UI.