Initial commit: 无人机行为规划后端系统
Made-with: Cursor
This commit is contained in:
43
main.py
Normal file
43
main.py
Normal file
@@ -0,0 +1,43 @@
|
||||
"""
|
||||
无人机行为规划后端 - FastAPI 入口
|
||||
|
||||
启动(请用 python -m 确保使用当前 conda 环境的依赖):
|
||||
python -m uvicorn main:app --reload --host 0.0.0.0 --port 8000
|
||||
|
||||
RAG 数据灌入(首次使用或更新知识库后需执行):
|
||||
python -m drone_planning.rag.ingestion
|
||||
|
||||
curl 示例:
|
||||
curl -X POST http://localhost:8000/api/plan -H "Content-Type: application/json" -d '{"text": "飞到大门然后拍照"}'
|
||||
curl -X POST http://localhost:8000/api/plan -H "Content-Type: application/json" -d '{"text": "起飞"}'
|
||||
"""
|
||||
|
||||
from fastapi import FastAPI
|
||||
from fastapi.middleware.cors import CORSMiddleware
|
||||
|
||||
from drone_planning.api.routes import router
|
||||
|
||||
app = FastAPI(
|
||||
title="无人机行为规划后端",
|
||||
description="从自然语言到行为树 JSON 的四层流水线",
|
||||
version="0.1.0",
|
||||
)
|
||||
|
||||
app.add_middleware(
|
||||
CORSMiddleware,
|
||||
allow_origins=["*"],
|
||||
allow_credentials=True,
|
||||
allow_methods=["*"],
|
||||
allow_headers=["*"],
|
||||
)
|
||||
|
||||
app.include_router(router)
|
||||
|
||||
@app.get("/")
|
||||
def root():
|
||||
return {"service": "drone-planning", "status": "ok"}
|
||||
|
||||
|
||||
@app.get("/health")
|
||||
def health():
|
||||
return {"status": "healthy"}
|
||||
Reference in New Issue
Block a user