Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/caarmen/notes
Explorations of different Python REST frameworks
https://github.com/caarmen/notes
alembic crud-sample django-rest-framework drf fastapi flask python rest sqlalchemy vanilla-python
Last synced: 11 days ago
JSON representation
Explorations of different Python REST frameworks
- Host: GitHub
- URL: https://github.com/caarmen/notes
- Owner: caarmen
- License: mit
- Created: 2023-10-07T16:12:05.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2023-11-21T21:09:55.000Z (12 months ago)
- Last Synced: 2023-11-21T22:25:10.782Z (12 months ago)
- Topics: alembic, crud-sample, django-rest-framework, drf, fastapi, flask, python, rest, sqlalchemy, vanilla-python
- Language: Python
- Homepage:
- Size: 49.8 KB
- Stars: 0
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Simple CRUD REST implementation
The purpose of this project is to explore different implementations of a REST server providing CRUD operations on "notes".
The notes have the following attributes:
* `id`: auto-increment primary key.
* `text`: a string.
* `created_at`: datetime automatically set when a note is created.
* `updated_at`: datetime automatically set when a note is updated.The data is stored in an SQLite database.
The server provides the following REST routes:
* Create a note: `POST /notes/`
* List notes: `GET /notes/`
* Get a note: `GET /notes//`
* Update a note: `PUT /notes//`
* Delete a note: `DELETE /notes//`## Implementations
Currently implementations are included for:
* FastAPI
* Flask
* Django REST Framework
* Vanilla (only python standard library, no external dependencies)The goal is to be able to compare the different frameworks and learn about their trade-offs.
## Running
In each of the implementations, the server can be run as follows:
Change directory into the implementation folder. For example, for fastapi:
```
cd fastapi
```Run the server with `./scripts/run.sh`.
Then, you can use the server:
*Create a note*:
```
curl -X POST -H "content-type: application/json" localhost:8000/notes/ -d '{"text": "some note text"} '
```*List all notes*:
```
curl localhost:8000/notes/
```*Read a note with id 1*:
```
curl localhost:8000/notes/1/
```*Modify the note with id 1*:
```
curl -X PUT -H "content-type: application/json" localhost:8000/notes/1/ -d '{"text": "some note text"} '
```*Delete the note with id 1*:
```
curl -X DELETE localhost:8000/notes/1/
```## Api documentation
The api documentation is available for all implementations:
* Openapi json: http://0.0.0.0:8000/openapi.json
* Swagger ui: http://0.0.0.0:8000/docs
* Redoc: http://0.0.0.0:8000/redoc## Limitations
* No user account management is implemented. Any client can modify and read all the notes.
* The project isn't currently Dockerized.
* No work has been done for deploying the servers in a production environment.
* The project structures may not be scalable. The goal of this project is to discover and compare some REST frameworks at an introductory level, not necessarily to demonstrate an architecture of a complex application.