Skip to content

vivek378521/fastapi-mongo

Repository files navigation

FastAPI Mongo

This is a sample FastAPI application that interacts with a MongoDB database.

Installation

  1. Clone this repository: git clone https://github.com/vivek378521/fastapi-mongo.git

  2. Create a virtual environment: python3 -m venv env I have used python3.9 for building this app, so if you have python version <3.7 you might face some issues

  3. Activate the virtual environment: source env/bin/activate

  4. Install the requirements: pip install -r requirements.txt

  5. Importing Data Before running the application, you'll need to import some sample data into your MongoDB database. To do this, run the import_data.py script: python import_data.py This script will create a new database named kimo and import some sample data into a collection named courses.

  6. Running the Tests To run the unit tests, run the pytest command: pytest courses_test.py These tests assume that the MongoDB database is running on the default port (27017) on the same machine as the application.

  7. Running the Application To run the FastAPI application, use the uvicorn command: uvicorn server:app --reload This will start the application on http://localhost:8000.

API Documentation

To view the API documentation, navigate to http://localhost:8000/docs in your web browser. This page is automatically generated by FastAPI and provides detailed documentation for all of the API endpoints.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages