solved API

This commit is contained in:
mpabi 2024-06-24 17:30:53 +00:00
parent 5a45abc524
commit 0363e941b1
3 changed files with 14 additions and 9 deletions

View File

@ -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)

View File

@ -17,4 +17,5 @@ class PassportData(PassportDataBase):
id: int id: int
class Config: class Config:
orm_mode: True orm_mode = True # Poprawne przypisanie

11
src/script/__post Normal file
View File

@ -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"
}'