22 lines
745 B
Python
22 lines
745 B
Python
from fastapi import FastAPI
|
|
|
|
from .routers import users, token, mail
|
|
from .dependencies import user_add
|
|
|
|
app = FastAPI()
|
|
|
|
app.include_router(users.router)
|
|
app.include_router(token.router)
|
|
app.include_router(mail.router)
|
|
|
|
|
|
@app.on_event("startup")
|
|
async def startup_event():
|
|
if len(os.environ["USERNAME_ADMIN"]) > 0 and len(os.environ["PASSWORD_ADMIN"]) > 0:
|
|
user_add.add(username=os.environ["USERNAME_ADMIN"], password=os.environ["PASSWORD_ADMIN"], roles="Admin")
|
|
if len(os.environ["USERNAME_TEST"]) > 0 and len(os.environ["PASSWORD_TEST"]) > 0:
|
|
user_add.add(username=os.environ["USERNAME_TEST"], password=os.environ["PASSWORD_TEST"], roles="User")
|
|
|
|
@app.get("/")
|
|
async def root():
|
|
return {"message": "Hello World !"} |