Browse Source

🎨 Update renamer script

pull/11/head
Sebastián Ramírez 6 years ago
parent
commit
ec7bec32ba
  1. 17
      docs/tutorial/src/tutorial34-01.py
  2. 29
      docs/tutorial/src/tutorial34-02.py
  3. 5
      scripts/rename_tutorial_src_files.py

17
docs/tutorial/src/tutorial34-01.py

@ -1,17 +0,0 @@
from fastapi import Body, FastAPI
from pydantic import BaseModel, Schema
app = FastAPI()
class Item(BaseModel):
name: str
description: str = Schema(None, title="The description of the item", max_length=300)
price: float = Schema(..., gt=0, description="The price must be greater than zero")
tax: float = None
@app.put("/items/{item_id}")
async def update_item(*, item_id: int, item: Item = Body(..., embed=True)):
results = {"item_id": item_id, "item": item}
return results

29
docs/tutorial/src/tutorial34-02.py

@ -1,29 +0,0 @@
from fastapi import Body, FastAPI
from pydantic import BaseModel, Schema
app = FastAPI()
class Item(BaseModel):
name: str
description: str = None
price: float
tax: float = None
@app.put("/items/{item_id}")
async def update_item(
*,
item_id: int,
item: Item = Body(
...,
example={
"name": "Foo",
"description": "A very nice Item",
"price": 35.4,
"tax": 3.2,
},
)
):
results = {"item_id": item_id, "item": item}
return results

5
scripts/rename_tutorial_src_files.py

@ -4,8 +4,9 @@ from string import digits
#%%
directory = Path("../docs/tutorial/src")
output_directory = Path("../docs/tutorial/out")
directory = Path("./docs/tutorial/src")
output_directory = Path("./docs/tutorial/out")
output_directory.mkdir(exist_ok=True)
files = sorted([Path(f) for f in directory.iterdir()])
for i, f in enumerate(files):
f: Path

Loading…
Cancel
Save