chore: initialize containerized Python learning workbook (2026 DevOps/SRE)
This commit is contained in:
commit
ae4c421815
63 files changed
+1273
No files matched your search
@@ -0,0 +1,26 @@
|
||||
from fastapi import FastAPI, HTTPException
|
||||
from pydantic import BaseModel
|
||||
|
||||
app = FastAPI(title="Python Learning API")
|
||||
|
||||
|
||||
class EchoRequest(BaseModel):
|
||||
message: str
|
||||
|
||||
|
||||
class EchoResponse(BaseModel):
|
||||
echoed: str
|
||||
length: int
|
||||
|
||||
|
||||
@app.get("/health")
|
||||
def health() -> dict[str, str]:
|
||||
raise NotImplementedError("Zwróć {'status': 'ok'}")
|
||||
|
||||
|
||||
@app.post("/echo", response_model=EchoResponse)
|
||||
def echo(payload: EchoRequest) -> EchoResponse:
|
||||
_ = HTTPException
|
||||
raise NotImplementedError(
|
||||
"Odrzuć pusty payload.message przez HTTPException(400), inaczej zwróć EchoResponse"
|
||||
)
|
||||
Reference in new issue
Block a user