solved API
This commit is contained in:
parent
5a45abc524
commit
0363e941b1
|
@ -26,14 +26,7 @@ def create_passport_data(passport_data: schemas.PassportDataCreate, db: Session
|
||||||
@app.get("/passport/{passport_number}", response_model=schemas.PassportData)
|
@app.get("/passport/{passport_number}", response_model=schemas.PassportData)
|
||||||
def read_passport_data(passport_number: str, db: Session = Depends(get_db)):
|
def read_passport_data(passport_number: str, db: Session = Depends(get_db)):
|
||||||
db_passport_data = db.query(models.PassportData).filter(models.PassportData.number == passport_number).first()
|
db_passport_data = db.query(models.PassportData).filter(models.PassportData.number == passport_number).first()
|
||||||
|
|
||||||
print ("---")
|
|
||||||
print (db_passport_data)
|
|
||||||
print ("---")
|
|
||||||
for key, value in vars(db_passport_data).items():
|
|
||||||
if not key.startswith('_'):
|
|
||||||
print(f'{key}: {value}')
|
|
||||||
|
|
||||||
if db_passport_data is None:
|
if db_passport_data is None:
|
||||||
raise HTTPException(status_code=404, detail="Passport data not found")
|
raise HTTPException(status_code=404, detail="Passport data not found")
|
||||||
return schemas.PassportData.from_orm(db_passport_data)
|
return schemas.PassportData.from_orm(db_passport_data)
|
||||||
|
|
||||||
|
|
|
@ -17,4 +17,5 @@ class PassportData(PassportDataBase):
|
||||||
id: int
|
id: int
|
||||||
|
|
||||||
class Config:
|
class Config:
|
||||||
orm_mode: True
|
orm_mode = True # Poprawne przypisanie
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,11 @@
|
||||||
|
curl -X POST "http://localhost:9999/passport/" \
|
||||||
|
-H "Content-Type: application/json" \
|
||||||
|
-d '{
|
||||||
|
"number": "444",
|
||||||
|
"name": null,
|
||||||
|
"surname": null,
|
||||||
|
"gender": null,
|
||||||
|
"fingerprint_url": "data/444-odcisk.jpg",
|
||||||
|
"photo_url": "data/444-zdjecie.jpg"
|
||||||
|
}'
|
||||||
|
|
Loading…
Reference in New Issue