You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

44 lines
1017 B

"""
{{ project_name }} - FastAPI Application
@author: {{ author }}
@date: {{ date }}
"""
from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
from app.database import engine, Base
{% for table in tables %}
from app.routers import {{ table.name_lower }}
{% endfor %}
# Create database tables
Base.metadata.create_all(bind=engine)
app = FastAPI(
title="{{ project_name }}",
description="{{ project_description }}",
version="1.0.0"
)
# CORS middleware
app.add_middleware(
CORSMiddleware,
allow_origins=["*"],
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)
# Include routers
{% for table in tables %}
app.include_router({{ table.name_lower }}.router, prefix="/api/{{ table.name_lower }}", tags=["{{ table.comment }}"])
{% endfor %}
@app.get("/")
async def root():
return {"message": "Welcome to {{ project_name }}"}
if __name__ == "__main__":
import uvicorn
uvicorn.run("main:app", host="0.0.0.0", port=8000, reload=True)