Simplified templating, backend port config on devserver.py, simplified Vue app patches.
This commit is contained in:
@@ -1,3 +0,0 @@
|
||||
"""{{PROJECT_TITLE}} package."""
|
||||
|
||||
__version__ = "0.1.0"
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
"""Entry point for the application."""
|
||||
|
||||
import sys
|
||||
|
||||
import uvicorn
|
||||
|
||||
|
||||
def main():
|
||||
"""Run the FastAPI application using uvicorn."""
|
||||
import uvicorn
|
||||
|
||||
if len(sys.argv) > 1:
|
||||
endpoint = sys.argv[1]
|
||||
@@ -18,10 +17,10 @@ def main():
|
||||
port = int(endpoint)
|
||||
else:
|
||||
host = "localhost"
|
||||
port = {{PROD_PORT}}
|
||||
port = 5080
|
||||
|
||||
uvicorn.run(
|
||||
"{{MODULE_NAME}}.app:app",
|
||||
"MODULE_NAME.app:app",
|
||||
host=host,
|
||||
port=port,
|
||||
log_level="info",
|
||||
|
||||
+8
-15
@@ -1,17 +1,12 @@
|
||||
"""Main FastAPI application."""
|
||||
|
||||
from contextlib import asynccontextmanager
|
||||
from pathlib import Path
|
||||
|
||||
from fastapi import FastAPI
|
||||
from fastapi_vue import Frontend
|
||||
|
||||
# Frontend static file server - configure options here
|
||||
# Vue Frontend static files
|
||||
frontend = Frontend(
|
||||
Path(__file__).parent / "frontend-build",
|
||||
spa=True,
|
||||
favicon="/assets/favicon",
|
||||
cached=["/assets/"],
|
||||
Path(__file__).with_name("frontend-build"), spa=True, cached=["/assets/"]
|
||||
)
|
||||
|
||||
|
||||
@@ -22,19 +17,17 @@ async def lifespan(app: FastAPI):
|
||||
yield
|
||||
|
||||
|
||||
app = FastAPI(title="{{PROJECT_TITLE}}", lifespan=lifespan)
|
||||
app = FastAPI(title="PROJECT_TITLE", lifespan=lifespan)
|
||||
|
||||
|
||||
# Add API routes here...
|
||||
|
||||
|
||||
# Health check endpoint for the Vue demo app to verify the backend is running
|
||||
@app.get("/api/health")
|
||||
async def health_check():
|
||||
"""Health check endpoint for the dev server."""
|
||||
return {"status": "ok"}
|
||||
|
||||
|
||||
# Add your API routes here
|
||||
# @app.get("/api/example")
|
||||
# async def example():
|
||||
# return {"message": "Hello World"}
|
||||
|
||||
|
||||
# Final catch-all route for frontend files (keep at end of file)
|
||||
frontend.route(app, "/")
|
||||
|
||||
Reference in New Issue
Block a user