예제 #1
0
from fastapi import FastAPI, HTTPException
from typing import Dict
from pydantic import BaseModel

app = FastAPI()

app.counter = -1


class PatientRequest(BaseModel):
    name: str
    surename: str


app.patients: Dict[int, PatientRequest] = {}


class PatientResponse(BaseModel):
    id: int
    patient: PatientRequest


class HelloResp(BaseModel):
    msg: str


@app.get('/')
def hello_world() -> str:
    return {'message': 'Hello World during the coronavirus pandemic!'}

예제 #2
0
import secrets
import sqlite3
from hashlib import sha256
from typing import Dict

from fastapi import FastAPI, HTTPException, Depends, Response, status, Cookie, Request
from fastapi.security import HTTPBasicCredentials, HTTPBasic

from pydantic import BaseModel

app = FastAPI()
app.patients = {}
app.counter = 0


@app.get("/")
def root():
    return {"message": "Hello World during the coronavirus pandemic!"}


class HelloResp(BaseModel):
    msg: str


@app.get("/hello/{name}", response_model=HelloResp)
def read_item(name: str):
    return HelloResp(msg=f"Hello {name}")


class GiveMeSomethingRq(BaseModel):
    first_key: str
예제 #3
0
파일: main.py 프로젝트: mateusz91t/PyLvlUp1
from fastapi import FastAPI, Response, Request
from fastapi.responses import HTMLResponse, JSONResponse
import fastapi_mako

from myservices.classmodels_to_sqlite import HelloNameResponse, PatientResponse, ToRegisterResponse
from myservices.auxiliary_methods import count, get_hash, get_len
from views.homework3 import homework3
from views.homework4 import homework4
from views.homework5 import homework5
from views.lecture3 import lecture2
from views.lecture4 import lecture4
from views.lecture5 import lecture5

app = FastAPI()

app.counter = count()
app.register_counter = count()
app.patient = dict()

app.include_router(lecture2, tags=["lecture2"])

app.__name__ = 'templates'
mako = fastapi_mako.FastAPIMako(app)

app.include_router(homework3, tags=["homework3"])
app.include_router(lecture4, prefix="/lec4", tags=["lecture4"])
app.include_router(homework4, tags=["homework4"])
app.include_router(lecture5, prefix="/lec5", tags=["lecture5"])
app.include_router(homework5, tags=["homework5"])