Skip to content

ZeroNiki/FastAPI-RestAPI-Example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Simple implementation of RestAPI (FastAPI)

For Django
A simple example of using RestAPi on FastAPI

Install

git clone https://github.com/ZeroNiki/FastAPI-RestAPI-Example.git

cd FastAPI-RestAPI-Example
python3 -m venv venv

source venv/bin/activate

pip insatll -r requirements.txt
alembic revision --autogenerate -m "INIT"

alembic upgrade head
uvicorn start:app --reload

go to http://localhost:8000/docs
Enjoy!

Usage

Curl

get all:

curl --request GET --url "localhost:8000/operations/data"

get todo:

curl --request GET --url "localhost:8000/operations/task/{id}"

add todo:

curl --header "Content-Type: application/json" \
--request POST \
--data '{"title": "title test"}' \
http://127.0.0.1:8000/operations/add

Update todo:

curl --header "Content-Type: application/json" \
--request PUT \
--data '{"title": "Update title test"}' \
http://127.0.0.1:8000/operations/update/{id}

Delete todo:

curl --request DELETE "localhost:8000/operations/delete/{id}"

Releases

No releases published

Packages

No packages published