{"id":15127519,"url":"https://github.com/saba-gul/fast-api-tutorial-with-docker","last_synced_at":"2026-02-08T12:08:18.500Z","repository":{"id":253044807,"uuid":"842291596","full_name":"Saba-Gul/FAST-API-Tutorial-With-Docker","owner":"Saba-Gul","description":"This is a simple FastAPI project that demonstrates basic API endpoints. The application provides a set of routes, including basic arithmetic, string manipulation, and a password checker.","archived":false,"fork":false,"pushed_at":"2024-08-14T04:11:16.000Z","size":139,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-05T19:18:43.956Z","etag":null,"topics":["docker","docker-compose","docker-container","docker-image","fastapi"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Saba-Gul.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-08-14T03:55:55.000Z","updated_at":"2024-08-14T04:11:19.000Z","dependencies_parsed_at":"2024-08-14T05:22:19.188Z","dependency_job_id":"f9afc9b7-f14e-46a3-9507-2a6b21166816","html_url":"https://github.com/Saba-Gul/FAST-API-Tutorial-With-Docker","commit_stats":null,"previous_names":["saba-gul/fast-api-tutorial-with-docker"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Saba-Gul%2FFAST-API-Tutorial-With-Docker","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Saba-Gul%2FFAST-API-Tutorial-With-Docker/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Saba-Gul%2FFAST-API-Tutorial-With-Docker/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Saba-Gul%2FFAST-API-Tutorial-With-Docker/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Saba-Gul","download_url":"https://codeload.github.com/Saba-Gul/FAST-API-Tutorial-With-Docker/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247386276,"owners_count":20930618,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["docker","docker-compose","docker-container","docker-image","fastapi"],"created_at":"2024-09-26T02:04:52.074Z","updated_at":"2026-02-08T12:08:18.461Z","avatar_url":"https://github.com/Saba-Gul.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Leveraging FastAPI With Docker\n\nThis is a simple FastAPI project that demonstrates basic API endpoints. The application provides a set of routes, including basic arithmetic, string manipulation, and a password checker.\n\n![My Image](whaley.jpeg)\n\n## Features\n\n- **Root Endpoint:** Returns a simple \"Hello World\" message.\n- **Even Number Generator:** Generates a string of even numbers.\n- **Password Checker:** Validates a username and password.\n\n## Getting Started\n\n### Prerequisites\n\nMake sure you have Python 3.7+ installed on your system. You also need to install the necessary dependencies, such as FastAPI, Uvicorn, and Nest Asyncio.\n\n### Installation\n\n1. **Clone the repository:**\n\n   ```bash\n   git clone https://github.com/your-username/your-repo-name.git\n   cd your-repo-name\n   ```\n\n2. **Create a virtual environment:**\n\n   ```bash\n   python3 -m venv venv\n   source venv/bin/activate  # On Windows use `venv\\Scripts\\activate`\n   ```\n\n3. **Install the required packages:**\n\n   ```bash\n   pip install -r requirements.txt\n   ```\n\n### Running the Application\n\nTo run the FastAPI application, use the following command:\n\n```bash\nuvicorn main:app --reload\n```\n\nThis will start the server, and you can access the API at `http://127.0.0.1:8000`.\n\n### Dockerization\n\nYou can also run this FastAPI application using Docker.\n\n1. **Build the Docker image:**\n\n   ```bash\n   docker build -t fastapi-app .\n   ```\n\n2. **Run the Docker container:**\n\n   ```bash\n   docker run -d -p 8000:8000 fastapi-app\n   ```\n\n   The application will be accessible at `http://localhost:8000`.\n\n### Dockerfile\n\nThe project includes a `Dockerfile` that sets up the environment for running the FastAPI application in a Docker container:\n\n```Dockerfile\n# Use the official Python 3.9 slim image as the base image\n# This is a lightweight version of Python with only the essential libraries\nFROM python:3.9-slim\n\n# Set the working directory inside the container to /app\n# All subsequent commands will be run in this directory\nWORKDIR /app\n\n# Copy the contents of the current directory (your project files) into the /app directory in the container\nCOPY . /app\n\n# Install the Python dependencies listed in requirements.txt\n# This ensures that all necessary packages for your FastAPI app are installed\nRUN pip install -r requirements.txt\n\n# Define the command to run the application\n# Uvicorn is used to serve the FastAPI application, with auto-reload enabled, on port 8000 and host 0.0.0.0\nCMD uvicorn main:app --reload --port=8000 --host=0.0.0.0\n```\n\n### Summary of Each Line:\n1. **`FROM python:3.9-slim`:** Specifies the base image as Python 3.9-slim, which is a minimal version of Python.\n2. **`WORKDIR /app`:** Sets `/app` as the working directory inside the container.\n3. **`COPY . /app`:** Copies the application code from the current directory on your local machine to the `/app` directory in the container.\n4. **`RUN pip install -r requirements.txt`:** Installs all the Python packages listed in the `requirements.txt` file.\n5. **`CMD uvicorn main:app --reload --port=8000 --host=0.0.0.0`:** Runs the FastAPI application using Uvicorn with the specified settings (reload on changes, port 8000, accessible on any network interface).\n### Available Endpoints\n\n#### Root Endpoint\n\n- **URL:** `/`\n- **Method:** `GET`\n- **Description:** Returns a simple message: \"Hello World\".\n\n#### Even Number Generator\n\n- **URL:** `/enwi`\n- **Method:** `GET`\n- **Description:** Generates a string of even numbers from 0 to 18.\n\n#### Password Checker\n\n- **URL:** `/a/{name}/{password}`\n- **Method:** `GET`\n- **Description:** Validates a username and password. The correct combination is \"abc\" and \"123\".\n\n### Example Usage\n\nYou can test the endpoints using Postman or `cURL`.\n\n#### Using Postman\n\n1. **Root Endpoint:**\n   - Method: `GET`\n   - URL: `http://127.0.0.1:8000/`\n\n2. **Even Number Generator:**\n   - Method: `GET`\n   - URL: `http://127.0.0.1:8000/enwi`\n\n3. **Password Checker:**\n   - Method: `GET`\n   - URL: `http://127.0.0.1:8000/a/abc/123`\n\n#### Using `cURL`\n\n1. **Root Endpoint:**\n   ```bash\n   curl -X GET \"http://127.0.0.1:8000/\"\n   ```\n\n2. **Even Number Generator:**\n   ```bash\n   curl -X GET \"http://127.0.0.1:8000/enwi\"\n   ```\n\n3. **Password Checker:**\n   ```bash\n   curl -X GET \"http://127.0.0.1:8000/a/abc/123\"\n   ```\n\n### Additional Information\n\n- **Project Structure:**\n  - `main.py`: The main FastAPI application file.\n  - `Dockerfile`: The Dockerfile for containerizing the application.\n  - `requirements.txt`: The file containing the list of dependencies.\n\n- **Dependencies:**\n  - `FastAPI`: A modern, fast (high-performance) web framework for building APIs with Python.\n  - `Uvicorn`: An ASGI server implementation, using `uvloop` and `httptools`.\n  - `Nest Asyncio`: Allows running async functions in environments where event loops are already running.\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsaba-gul%2Ffast-api-tutorial-with-docker","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsaba-gul%2Ffast-api-tutorial-with-docker","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsaba-gul%2Ffast-api-tutorial-with-docker/lists"}