https://github.com/roblesdotdev/flask-rest
REST Apis with flask
https://github.com/roblesdotdev/flask-rest
Last synced: 12 months ago
JSON representation
REST Apis with flask
- Host: GitHub
- URL: https://github.com/roblesdotdev/flask-rest
- Owner: roblesdotdev
- Created: 2023-06-12T20:02:20.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2023-06-13T00:00:44.000Z (about 3 years ago)
- Last Synced: 2025-03-03T08:44:56.439Z (over 1 year ago)
- Language: Python
- Size: 3.91 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Flask Rest
### Setup Environment
```
python3 -m venv .venv
source .venv/bin/activate
pip install flask
```
### Setup flask app
```
# app.py
from flask import Flask
app = Flask(__name__)
@app.get("/")
def greet():
return { "message": "Hello World" }
```
```
# Makefile
run:
flask run --debug
```
### Create API Specification
```
# oas.yaml
openapi: 3.0.3
info:
title: FLASK REST API
description: API to learn flask
version: 1.0.0
paths:
/stores:
get:
summary: Returns a list of store items
responses:
'200':
description: A JSON array of stores
content:
application/json:
schema:
$ref: '#/components/schemas/ListStoresSchema'
# ...
```
### Implement endpoints
```
@app.get("/stores")
def get_stores():
return {"stores": stores}
```