- Backend: Refactored tasks.py to directly invoke run_single_fna_pipeline.py for consistency. - Backend: Changed output format to ZIP and added auto-cleanup of intermediate files. - Backend: Fixed language parameter passing in API and tasks. - Frontend: Removed CRISPR Fusion UI elements from Submit and Monitor views. - Frontend: Implemented simulated progress bar for better UX. - Frontend: Restored One-click load button and added result file structure documentation. - Docker: Fixed critical Restarting loop by removing incorrect image directive in docker-compose.yml. - Docker: Optimized Dockerfile to correct .pixi environment path issues and prevent accidental deletion of frontend assets.
56 lines
1.5 KiB
Python
56 lines
1.5 KiB
Python
"""FastAPI 主应用"""
|
|
from fastapi import FastAPI
|
|
from fastapi.middleware.cors import CORSMiddleware
|
|
from contextlib import asynccontextmanager
|
|
|
|
from .config import settings
|
|
from .api.v1 import jobs, upload, results, tasks, examples
|
|
|
|
|
|
@asynccontextmanager
|
|
async def lifespan(app: FastAPI):
|
|
"""应用生命周期管理"""
|
|
# 启动时
|
|
print("🚀 Starting BtToxin Pipeline API...")
|
|
yield
|
|
# 关闭时
|
|
print("👋 Shutting down BtToxin Pipeline API...")
|
|
|
|
|
|
app = FastAPI(
|
|
title=settings.APP_NAME,
|
|
version=settings.APP_VERSION,
|
|
description="Automated Bacillus thuringiensis toxin mining pipeline",
|
|
lifespan=lifespan
|
|
)
|
|
|
|
# CORS
|
|
app.add_middleware(
|
|
CORSMiddleware,
|
|
allow_origins=settings.CORS_ORIGINS,
|
|
allow_credentials=True,
|
|
allow_methods=["*"],
|
|
allow_headers=["*"],
|
|
)
|
|
|
|
# 路由
|
|
app.include_router(jobs.router, prefix=f"{settings.API_V1_STR}/jobs", tags=["jobs"])
|
|
app.include_router(tasks.router, prefix=f"{settings.API_V1_STR}/tasks", tags=["tasks"])
|
|
app.include_router(upload.router, prefix=f"{settings.API_V1_STR}/upload", tags=["upload"])
|
|
app.include_router(examples.router, prefix=f"{settings.API_V1_STR}/examples", tags=["examples"])
|
|
app.include_router(results.router, prefix=f"{settings.API_V1_STR}/results", tags=["results"])
|
|
|
|
|
|
@app.get("/")
|
|
async def root():
|
|
return {
|
|
"name": settings.APP_NAME,
|
|
"version": settings.APP_VERSION,
|
|
"status": "healthy"
|
|
}
|
|
|
|
|
|
@app.get("/health")
|
|
async def health():
|
|
return {"status": "ok"}
|