35 lines
781 B
Python
35 lines
781 B
Python
from fastapi import FastAPI
|
|
from fastapi.middleware.cors import CORSMiddleware
|
|
import models
|
|
from database import engine
|
|
from routers import tasks, reminders
|
|
|
|
# Create database tables
|
|
models.Base.metadata.create_all(bind=engine)
|
|
|
|
app = FastAPI(
|
|
title="Task Manager API",
|
|
description="Backend API for managing tasks and reminders for Web and Telegram.",
|
|
version="1.0.0"
|
|
)
|
|
|
|
# CORS configuration
|
|
origins = [
|
|
"*" # Adjust this in production
|
|
]
|
|
app.add_middleware(
|
|
CORSMiddleware,
|
|
allow_origins=origins,
|
|
allow_credentials=True,
|
|
allow_methods=["*"],
|
|
allow_headers=["*"],
|
|
)
|
|
|
|
# Include routers
|
|
app.include_router(tasks.router)
|
|
app.include_router(reminders.router)
|
|
|
|
@app.get("/")
|
|
def read_root():
|
|
return {"message": "Welcome to the Task Manager API"}
|