Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 0 additions & 54 deletions example/api.yatl.yaml

This file was deleted.

9 changes: 9 additions & 0 deletions examples/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Examples for Different Frameworks

## FastAPI
- [English](fastapi/README.en.md)
- [Русский](fastapi/README.ru.md)

## Flask
- [English](flask/README.en.md)
- [Русский](flask/README.ru.md)
1 change: 1 addition & 0 deletions examples/fastapi/README.en.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
...
1 change: 1 addition & 0 deletions examples/fastapi/README.ru.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
...
12 changes: 0 additions & 12 deletions example/api.py → examples/fastapi/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,9 @@
from pydantic import BaseModel


class UserInfo(BaseModel):
email: str
phone: str


class User(BaseModel):
name: str
age: int
info: UserInfo


app = FastAPI()
Expand All @@ -19,7 +13,6 @@ class User(BaseModel):
1: {
"name": "John Doe",
"age": 30,
"info": {"email": "john.doe@example.com", "phone": "1234567890"},
}
}

Expand All @@ -38,11 +31,6 @@ def create_user(user: User):
return users[user_id]


@app.get("/users")
def user_count():
return {"count": len(users)}


if __name__ == "__main__":
import uvicorn

Expand Down
Empty file added examples/fastapi/api.yatl.yaml
Empty file.
1 change: 1 addition & 0 deletions examples/flask/README.en.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
...
1 change: 1 addition & 0 deletions examples/flask/README.ru.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
...
35 changes: 35 additions & 0 deletions examples/flask/api.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
from flask import Flask, request, jsonify

app = Flask(__name__)

users = {
1: {
"name": "John Doe",
"age": 30,
}
}


@app.get("/users/<int:user_id>")
def get_user(user_id):
if user_id not in users:
return jsonify({"detail": "User not found"}), 404
return jsonify(users[user_id])


@app.post("/users")
def create_user():
data = request.get_json()
if not data or "name" not in data or "age" not in data:
return jsonify({"detail": "Invalid input"}), 400

user_id = len(users) + 1
users[user_id] = {
"name": data["name"],
"age": data["age"],
}
return jsonify(users[user_id]), 201


if __name__ == "__main__":
app.run(host="0.0.0.0", port=8000)
Empty file added examples/flask/api.yatl.yaml
Empty file.
641 changes: 322 additions & 319 deletions poetry.lock

Large diffs are not rendered by default.

Loading