https://github.com/zeroniki/fastapi-restapi-example
https://github.com/zeroniki/fastapi-restapi-example
fastapi python3 rest-api restapi sqlalchemy sqlite
Last synced: 4 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/zeroniki/fastapi-restapi-example
- Owner: ZeroNiki
- Created: 2024-09-17T08:45:34.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-09-17T09:58:55.000Z (almost 2 years ago)
- Last Synced: 2025-08-14T12:44:54.451Z (10 months ago)
- Topics: fastapi, python3, rest-api, restapi, sqlalchemy, sqlite
- Language: Python
- Homepage:
- Size: 8.79 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Simple implementation of RestAPI (FastAPI)
[For Django](https://github.com/ZeroNiki/Django-RestAPI-Example)
A simple example of using RestAPi on FastAPI
## Install
```bash
git clone https://github.com/ZeroNiki/FastAPI-RestAPI-Example.git
cd FastAPI-RestAPI-Example
```
```bash
python3 -m venv venv
source venv/bin/activate
pip insatll -r requirements.txt
```
```bash
alembic revision --autogenerate -m "INIT"
alembic upgrade head
```
```bash
uvicorn start:app --reload
```
go to http://localhost:8000/docs
Enjoy!
## Usage
### Curl
get all:
```bash
curl --request GET --url "localhost:8000/operations/data"
```
get todo:
```bash
curl --request GET --url "localhost:8000/operations/task/{id}"
```
add todo:
```bash
curl --header "Content-Type: application/json" \
--request POST \
--data '{"title": "title test"}' \
http://127.0.0.1:8000/operations/add
```
Update todo:
```bash
curl --header "Content-Type: application/json" \
--request PUT \
--data '{"title": "Update title test"}' \
http://127.0.0.1:8000/operations/update/{id}
```
Delete todo:
```bash
curl --request DELETE "localhost:8000/operations/delete/{id}"
```