Skip to content

Ngounse/fast-api_

Repository files navigation

Installation

# pip install fastapi

You will also need an ASGI server, for production such as Uvicorn or Hypercorn.

# pip install "uvicorn[standard]"

Run it

Run the server with:

# uvicorn main:app --reload

http://127.0.0.1:8000/redoc

MongoDB with FastAPI

This is a small sample project demonstrating how to build an API with MongoDB and FastAPI. It was written to accompany a blog post - you should go read it!

TL;DR

If you really don't want to read the blog post and want to get up and running, activate your Python virtualenv, and then run the following from your terminal (edit the DB_URL first!):

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

# Configure the location of your MongoDB database:
export MONGODB_URL="mongodb+srv://<username>:<password>@<url>/<db>?retryWrites=true&w=majority"

# Start the service:
# cd fast_\&_mongodb
# uvicorn app:app --reload

(Check out MongoDB Atlas if you need a MongoDB database.)

Now you can load http://localhost:8000 in your browser ... but there won't be much to see until you've inserted some data.

If you have any questions or suggestions, check out the MongoDB Community Forums!

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published