Platform-as-a-service in your own Cloud
withcoherence.com
This is the code to accompany the tutorial available at our Framework Guide (FastAPI) page.
You can use it as a starting point for any full stack FastAPI application. Read the guide to see how to deploy it to a production environment in your own cloud, or see the instructions below to run a development version of it locally.
Fork the repository to your GitHub account. To test locally, clone the forked repository to your machine. You will need to have Docker installed.
Before you begin, ensure you have the following installed on your system:
- Python 3.8+
- PostgreSQL
- pip (Python package manager)
-
Clone the repository:
git clone https://github.com/<your-username>/fastapi-employee-app.git cd fastapi-employee-app
-
Create a virtual environment and activate it:
python -m venv venv source venv/bin/activate # On Windows use `venv\Scripts\activate`
-
Install the required packages:
pip install -r requirements.txt
-
Create a PostgreSQL database for the project:
createdb employee_app
-
Create a
.env
file in the root directory with the following content:DB_USER=your_postgres_username DB_PASSWORD=your_postgres_password DB_HOST=localhost DB_NAME=employee_app
Replace
your_postgres_username
andyour_postgres_password
with your actual PostgreSQL credentials. -
Run the database migrations:
alembic upgrade head
-
Start the FastAPI server:
uvicorn app.main:app --reload
-
Open your web browser and navigate to
http://localhost:8000
to access the application.
Take a look at the following for more information:
Cloud Infrastructure On Autopilot
Deploy containerized and serverless apps to your own cloud in minutes, not weeks.