Skip to content

Commit

Permalink
Deployed 856231c with MkDocs version: 1.5.3
Browse files Browse the repository at this point in the history
  • Loading branch information
dunossauro committed Apr 17, 2024
1 parent 02922aa commit 1f2c3f8
Show file tree
Hide file tree
Showing 37 changed files with 2,568 additions and 1,831 deletions.
904 changes: 484 additions & 420 deletions 01/index.html

Large diffs are not rendered by default.

347 changes: 215 additions & 132 deletions 02/index.html

Large diffs are not rendered by default.

380 changes: 196 additions & 184 deletions 03/index.html

Large diffs are not rendered by default.

200 changes: 105 additions & 95 deletions 04/index.html

Large diffs are not rendered by default.

213 changes: 130 additions & 83 deletions 05/index.html

Large diffs are not rendered by default.

235 changes: 126 additions & 109 deletions 06/index.html

Large diffs are not rendered by default.

1,014 changes: 567 additions & 447 deletions 07/index.html

Large diffs are not rendered by default.

40 changes: 20 additions & 20 deletions 08/index.html

Large diffs are not rendered by default.

502 changes: 282 additions & 220 deletions 09/index.html

Large diffs are not rendered by default.

116 changes: 55 additions & 61 deletions 10/index.html

Large diffs are not rendered by default.

32 changes: 16 additions & 16 deletions 11/index.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions 12/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@


<link rel="icon" href="../assets/logo.svg">
<meta name="generator" content="mkdocs-1.5.3, mkdocs-material-9.5.15">
<meta name="generator" content="mkdocs-1.5.3, mkdocs-material-9.5.17">



<title>Fazendo deploy no Fly.io - FastAPI do Zero</title>



<link rel="stylesheet" href="../assets/stylesheets/main.7e359304.min.css">
<link rel="stylesheet" href="../assets/stylesheets/main.bcfcd587.min.css">


<link rel="stylesheet" href="../assets/stylesheets/palette.06af60db.min.css">
Expand Down Expand Up @@ -1326,7 +1326,7 @@ <h2 id="conclusao">Conclusão</h2>
<script id="__config" type="application/json">{"base": "..", "features": ["content.code.annotate", "content.code.copy", "content.tabs.link", "search.suggest", "search.highlight", "search.share"], "search": "../assets/javascripts/workers/search.b8dbb3d2.min.js", "translations": {"clipboard.copied": "Copiado para \u00e1rea de transfer\u00eancia", "clipboard.copy": "Copiar para \u00e1rea de transfer\u00eancia", "search.result.more.one": "mais 1 nesta p\u00e1gina", "search.result.more.other": "# mais nesta p\u00e1gina", "search.result.none": "Nenhum documento encontrado", "search.result.one": "1 documento encontrado", "search.result.other": "# documentos encontrados", "search.result.placeholder": "Digite para iniciar a busca", "search.result.term.missing": "Ausente", "select.version": "Selecione a vers\u00e3o"}}</script>


<script src="../assets/javascripts/bundle.bd41221c.min.js"></script>
<script src="../assets/javascripts/bundle.1e8ae164.min.js"></script>


<script>document$.subscribe(() => {const lightbox = GLightbox({"touchNavigation": true, "loop": false, "zoomable": true, "draggable": true, "openEffect": "zoom", "closeEffect": "zoom", "slideEffect": "slide"});})</script></body>
Expand Down
6 changes: 3 additions & 3 deletions 13/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@


<link rel="icon" href="../assets/logo.svg">
<meta name="generator" content="mkdocs-1.5.3, mkdocs-material-9.5.15">
<meta name="generator" content="mkdocs-1.5.3, mkdocs-material-9.5.17">



<title>Despedida e próximos passos - FastAPI do Zero</title>



<link rel="stylesheet" href="../assets/stylesheets/main.7e359304.min.css">
<link rel="stylesheet" href="../assets/stylesheets/main.bcfcd587.min.css">


<link rel="stylesheet" href="../assets/stylesheets/palette.06af60db.min.css">
Expand Down Expand Up @@ -1186,7 +1186,7 @@ <h2 id="conclusao">Conclusão</h2>
<script id="__config" type="application/json">{"base": "..", "features": ["content.code.annotate", "content.code.copy", "content.tabs.link", "search.suggest", "search.highlight", "search.share"], "search": "../assets/javascripts/workers/search.b8dbb3d2.min.js", "translations": {"clipboard.copied": "Copiado para \u00e1rea de transfer\u00eancia", "clipboard.copy": "Copiar para \u00e1rea de transfer\u00eancia", "search.result.more.one": "mais 1 nesta p\u00e1gina", "search.result.more.other": "# mais nesta p\u00e1gina", "search.result.none": "Nenhum documento encontrado", "search.result.one": "1 documento encontrado", "search.result.other": "# documentos encontrados", "search.result.placeholder": "Digite para iniciar a busca", "search.result.term.missing": "Ausente", "select.version": "Selecione a vers\u00e3o"}}</script>


<script src="../assets/javascripts/bundle.bd41221c.min.js"></script>
<script src="../assets/javascripts/bundle.1e8ae164.min.js"></script>


<script>document$.subscribe(() => {const lightbox = GLightbox({"touchNavigation": true, "loop": false, "zoomable": true, "draggable": true, "openEffect": "zoom", "closeEffect": "zoom", "slideEffect": "slide"});})</script></body>
Expand Down
6 changes: 3 additions & 3 deletions 404.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@


<link rel="icon" href="/assets/logo.svg">
<meta name="generator" content="mkdocs-1.5.3, mkdocs-material-9.5.15">
<meta name="generator" content="mkdocs-1.5.3, mkdocs-material-9.5.17">



<title>FastAPI do Zero</title>



<link rel="stylesheet" href="/assets/stylesheets/main.7e359304.min.css">
<link rel="stylesheet" href="/assets/stylesheets/main.bcfcd587.min.css">


<link rel="stylesheet" href="/assets/stylesheets/palette.06af60db.min.css">
Expand Down Expand Up @@ -712,7 +712,7 @@ <h1>404 - Not found</h1>
<script id="__config" type="application/json">{"base": "/", "features": ["content.code.annotate", "content.code.copy", "content.tabs.link", "search.suggest", "search.highlight", "search.share"], "search": "/assets/javascripts/workers/search.b8dbb3d2.min.js", "translations": {"clipboard.copied": "Copiado para \u00e1rea de transfer\u00eancia", "clipboard.copy": "Copiar para \u00e1rea de transfer\u00eancia", "search.result.more.one": "mais 1 nesta p\u00e1gina", "search.result.more.other": "# mais nesta p\u00e1gina", "search.result.none": "Nenhum documento encontrado", "search.result.one": "1 documento encontrado", "search.result.other": "# documentos encontrados", "search.result.placeholder": "Digite para iniciar a busca", "search.result.term.missing": "Ausente", "select.version": "Selecione a vers\u00e3o"}}</script>


<script src="/assets/javascripts/bundle.bd41221c.min.js"></script>
<script src="/assets/javascripts/bundle.1e8ae164.min.js"></script>


</body>
Expand Down
Binary file modified assets/03/cobertura_get_sem_testes.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/05/coverage_mostrando_casos_nao_testados_de_erro.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion assets/stylesheets/main.7e359304.min.css

This file was deleted.

1 change: 0 additions & 1 deletion assets/stylesheets/main.7e359304.min.css.map

This file was deleted.

1 change: 1 addition & 0 deletions assets/stylesheets/main.bcfcd587.min.css

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions assets/stylesheets/main.bcfcd587.min.css.map

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions aulas/sincronas/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@


<link rel="icon" href="../../assets/logo.svg">
<meta name="generator" content="mkdocs-1.5.3, mkdocs-material-9.5.15">
<meta name="generator" content="mkdocs-1.5.3, mkdocs-material-9.5.17">



<title>Aulas síncronas - FastAPI do Zero</title>



<link rel="stylesheet" href="../../assets/stylesheets/main.7e359304.min.css">
<link rel="stylesheet" href="../../assets/stylesheets/main.bcfcd587.min.css">


<link rel="stylesheet" href="../../assets/stylesheets/palette.06af60db.min.css">
Expand Down Expand Up @@ -1017,7 +1017,7 @@ <h2 id="o-que-sera-necessario-para-acompanhar">O que será necessário para acom
<script id="__config" type="application/json">{"base": "../..", "features": ["content.code.annotate", "content.code.copy", "content.tabs.link", "search.suggest", "search.highlight", "search.share"], "search": "../../assets/javascripts/workers/search.b8dbb3d2.min.js", "translations": {"clipboard.copied": "Copiado para \u00e1rea de transfer\u00eancia", "clipboard.copy": "Copiar para \u00e1rea de transfer\u00eancia", "search.result.more.one": "mais 1 nesta p\u00e1gina", "search.result.more.other": "# mais nesta p\u00e1gina", "search.result.none": "Nenhum documento encontrado", "search.result.one": "1 documento encontrado", "search.result.other": "# documentos encontrados", "search.result.placeholder": "Digite para iniciar a busca", "search.result.term.missing": "Ausente", "select.version": "Selecione a vers\u00e3o"}}</script>


<script src="../../assets/javascripts/bundle.bd41221c.min.js"></script>
<script src="../../assets/javascripts/bundle.1e8ae164.min.js"></script>


<script>document$.subscribe(() => {const lightbox = GLightbox({"touchNavigation": true, "loop": false, "zoomable": true, "draggable": true, "openEffect": "zoom", "closeEffect": "zoom", "slideEffect": "slide"});})</script></body>
Expand Down
8 changes: 8 additions & 0 deletions codigos/01/fast_zero/app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from fastapi import FastAPI

app = FastAPI()


@app.get('/')
def read_root():
return {'message': 'Olá Mundo!'}
46 changes: 46 additions & 0 deletions codigos/01/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
[tool.poetry]
name = "fast-zero"
version = "0.1.0"
description = ""
authors = ["Your Name <[email protected]>"]
readme = "README.md"

[tool.poetry.dependencies]
python = "3.12.*" # ou 3.11.*
fastapi = "^0.109.2"
uvicorn = "^0.27.0.post1"

[tool.poetry.group.dev.dependencies]
pytest = "^8.0.0"
pytest-cov = "^4.1.0"
taskipy = "^1.12.2"
ruff = "^0.2.1"
httpx = "^0.26.0"

[tool.ruff]
line-length = 79
extend-exclude = ['migrations']

[tool.ruff.lint]
preview = true
select = ['I', 'F', 'E', 'W', 'PL', 'PT']

[tool.ruff.format]
preview = true
quote-style = 'single'

[tool.pytest.ini_options]
pythonpath = "."
addopts = '-p no:warnings'

[tool.taskipy.tasks]
lint = 'ruff check .; ruff check . --diff'
format = 'ruff check . --fix; ruff format .'
run = 'uvicorn fast_zero.app:app --reload'
pre_test = 'task lint'
test = 'pytest -s -x --cov=fast_zero -vv'
post_test = 'coverage html'

[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
37 changes: 37 additions & 0 deletions codigos/01/tests/test_app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
from fastapi.testclient import TestClient # (1)!

from fast_zero.app import app # (2)!

client = TestClient(app) # (3)!


from http import HTTPStatus # (6)!

from fastapi.testclient import TestClient

from fast_zero.app import app


def test_root_deve_retornar_ok_e_ola_mundo(): # (1)!
client = TestClient(app) # (2)!

response = client.get('/') # (3)!

assert response.status_code == HTTPStatus.OK # (4)!
assert response.json() == {'message': 'Olá Mundo!'} # (5)!


from http import HTTPStatus

from fastapi.testclient import TestClient

from fast_zero.app import app


def test_root_deve_retornar_ok_e_ola_mundo():
client = TestClient(app) # Arrange

response = client.get('/') # Act

assert response.status_code == HTTPStatus.OK # Assert
assert response.json() == {'message': 'Olá Mundo!'} # Assert
95 changes: 95 additions & 0 deletions codigos/03/fast_zero/app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
from fastapi import FastAPI

app = FastAPI()


@app.post('/users/')
def create_user():
...


from http import HTTPStatus

# ...

@app.post('/users/', status_code=HTTPStatus.CREATED)
def create_user():
...


from fast_zero.schemas import Message, UserSchema

# ...

@app.post('/users/', status_code=HTTPStatus.CREATED)
def create_user(user: UserSchema):
...


from fast_zero.schemas import Message, UserPublic, UserSchema

# Código omitido

@app.post('/users/', status_code=HTTPStatus.CREATED, response_model=UserPublic)
def create_user(user: UserSchema):
...


@app.post('/users/', status_code=HTTPStatus.CREATED, response_model=UserPublic)
def create_user(user: UserSchema):
return user


from fast_zero.schemas import Message, UserDB, UserPublic, UserSchema

# código omitido

database = [] #(1)!

# código omitido

@app.post('/users/', status_code=HTTPStatus.CREATED, response_model=UserPublic)
def create_user(user: UserSchema):
user_with_id = UserDB(**user.model_dump(), id=len(database) + 1) #(2)!

database.append(user_with_id)

return user_with_id


from fast_zero.schemas import Message, UserDB, UserList, UserPublic, UserSchema

# código omitido

@app.get('/users/', response_model=UserList)
def read_users():
return {'users': database}


from fastapi import FastAPI, HTTPException

# ...

@app.put('/users/{user_id}', response_model=UserPublic)
def update_user(user_id: int, user: UserSchema):
if user_id > len(database) or user_id < 1: #(1)!
raise HTTPException(
status_code=HTTPStatus.NOT_FOUND, detail='User not found'
) #(2)!

user_with_id = UserDB(**user.model_dump(), id=user_id)
database[user_id - 1] = user_with_id #(3)!

return user_with_id


@app.delete('/users/{user_id}', response_model=Message)
def delete_user(user_id: int):
if user_id > len(database) or user_id < 1:
raise HTTPException(
status_code=HTTPStatus.NOT_FOUND, detail='User not found'
)

del database[user_id - 1]

return {'message': 'User deleted'}
36 changes: 36 additions & 0 deletions codigos/03/fast_zero/schemas.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
from pydantic import BaseModel, EmailStr


class Message(BaseModel):
message: str


class UserSchema(BaseModel):
username: str
email: EmailStr
password: str


class UserPublic(BaseModel):
id: int
username: str
email: EmailStr


class UserDB(UserSchema):
id: int


class UserList(BaseModel):
users: list[UserPublic]


class UserSchema(BaseModel):
username: str
email: str
password: str


class UserPublic(BaseModel):
username: str
email: str
9 changes: 9 additions & 0 deletions codigos/03/tests/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import pytest
from fastapi.testclient import TestClient

from fast_zero.app import app


@pytest.fixture()
def client():
return TestClient(app)
Loading

0 comments on commit 1f2c3f8

Please sign in to comment.