32 lines
728 B
Python
32 lines
728 B
Python
from fastapi import FastAPI
|
|
from fastapi.middleware.cors import CORSMiddleware
|
|
from sqlalchemy.orm import Session
|
|
from .routers import auth, user, service, student, job
|
|
from .database import init_db, engine
|
|
from .models import Base
|
|
|
|
Base.metadata.create_all(engine)
|
|
|
|
with Session(engine) as session:
|
|
init_db(session)
|
|
|
|
app = FastAPI()
|
|
|
|
origins = ["*"]
|
|
|
|
app.add_middleware(
|
|
CORSMiddleware,
|
|
allow_origins=origins,
|
|
allow_credentials=True,
|
|
allow_methods=["*"],
|
|
allow_headers=["*"],
|
|
)
|
|
app.include_router(auth.router)
|
|
app.include_router(user.router)
|
|
app.include_router(student.router)
|
|
app.include_router(job.router)
|
|
app.include_router(service.router)
|
|
|
|
@app.get("/")
|
|
def root():
|
|
return {"message": "I'm ok!"} |