Skip to content

NYCU-SDC/fastapi-env

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

FastAPI Environment

This project is designed specifically for programs related to FastAPI. It aims to allow students to focus on learning FastAPI without worrying about environment setup. The project includes the necessary configurations and dependencies to start quickly and easily.

Prerequisites

Make sure you have the following software installed on your machine:

  • Git
  • Docker Desktop or Docker Engine

Project Structure

The project is structured as follows:

  • requirements.txt: Lists the Python dependencies required for the project.
  • Dockerfile: Contains the instructions to build the Docker image for the FastAPI application.
  • docker-compose.yaml: Defines the services and configurations for running the project using Docker Compose.
  • app/: Directory containing the FastAPI application code.

Setup Instructions

  1. Clone the repository:

    git clone <repository_url>
    cd <repository_directory>
  2. Build and start the application using Docker Compose:

    docker-compose up --build -d
  3. Build Hello World App:

  • Create a directory fastapi-env/app
  • Create a file app/main.py
  • Paste Hello World code.
    from fastapi import FastAPI
    
    app = FastAPI()
    
    
    @app.get("/")
    async def root():
        return {"message": "Hello World"}
  1. Access the FastAPI application: The FastAPI application will be available at http://localhost:8080.

Dockerfile

The Dockerfile sets up the environment for the FastAPI application. It includes the following key steps:

  • Use an official Python base image.
  • Set the working directory.
  • Copy the necessary files.
  • Install the required Python packages.
  • Specify the command to run the FastAPI application.

Docker Compose

The docker-compose.yaml file defines the services required for the application. It includes:

  • The FastAPI service, built from the Dockerfile.
  • Configuration for environment variables and port mappings.
  • PostgreSQL database service and PGAdmin4.

Contact

For any questions or issues, please contact the project maintainer at [email protected].

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published