Add app/main.py
This commit is contained in:
parent
71e6130f96
commit
883656b1a4
1 changed files with 27 additions and 0 deletions
27
app/main.py
Normal file
27
app/main.py
Normal file
|
|
@ -0,0 +1,27 @@
|
||||||
|
from fastapi import FastAPI
|
||||||
|
from app import crud, schemas
|
||||||
|
from app.database import SessionLocal, engine
|
||||||
|
from app import models
|
||||||
|
|
||||||
|
# Create tables if not exist
|
||||||
|
models.Base.metadata.create_all(bind=engine)
|
||||||
|
|
||||||
|
app = FastAPI(title="Data Lab API")
|
||||||
|
|
||||||
|
@app.get("/")
|
||||||
|
def root():
|
||||||
|
return {"message": "Welcome to Data Lab API"}
|
||||||
|
|
||||||
|
@app.get("/customers")
|
||||||
|
def get_customers():
|
||||||
|
db = SessionLocal()
|
||||||
|
customers = crud.get_customers(db)
|
||||||
|
db.close()
|
||||||
|
return customers
|
||||||
|
|
||||||
|
@app.get("/accounts")
|
||||||
|
def get_accounts():
|
||||||
|
db = SessionLocal()
|
||||||
|
accounts = crud.get_accounts(db)
|
||||||
|
db.close()
|
||||||
|
return accounts
|
||||||
Loading…
Reference in a new issue