Home¶
Fasteve is a rebuild of Eve using FastAPI as a base.
Installation¶
$ pip install fasteve
---> 100%
Example¶
Create a file main.py
with:
from fasteve import Fasteve, MongoModel, Resource
class People(MongoModel):
name: str
people = Resource(model=People)
resources = [people]
app = Fasteve(resources=resources)
Start a database (mongodb default):
$ docker run --rm -p 27017:27017 mongo
Run the server with:
$ uvicorn main:app --reload
The API is now live, ready to be consumed:
$ curl -i http://localhost:8000/people
HTTP/1.1 200
...
{
"_data": [],
"_meta": {"max_results": 25, "total": 0, "page": 1},
"_links": {
"self": {"href": "/people", "title": "people"},
"parent": {"href": "/", "title": "home"},
},
}