deving
This commit is contained in:
@@ -33,6 +33,7 @@ tasks = {}
|
||||
|
||||
|
||||
@router.get("/")
|
||||
@router.post("/")
|
||||
async def read_root(request: Request):
|
||||
"""主页面"""
|
||||
from fastapi.templating import Jinja2Templates
|
||||
@@ -48,6 +49,7 @@ async def read_root(request: Request):
|
||||
|
||||
|
||||
@router.get("/health")
|
||||
@router.post("/health")
|
||||
async def health():
|
||||
return {
|
||||
"status": "healthy",
|
||||
@@ -113,6 +115,7 @@ async def upload_stp(
|
||||
|
||||
|
||||
@router.get("/status/{task_id}")
|
||||
@router.post("/status/{task_id}")
|
||||
async def get_status(task_id: str):
|
||||
"""获取任务状态"""
|
||||
if task_id not in tasks:
|
||||
@@ -124,6 +127,7 @@ async def get_status(task_id: str):
|
||||
|
||||
|
||||
@router.get("/debug/tasks")
|
||||
@router.post("/debug/tasks")
|
||||
async def debug_tasks():
|
||||
"""调试接口:查看所有任务"""
|
||||
return {
|
||||
@@ -133,6 +137,7 @@ async def debug_tasks():
|
||||
|
||||
|
||||
@router.get("/api/history")
|
||||
@router.post("/api/history")
|
||||
async def get_file_history():
|
||||
"""获取按文件名分组的文件历史记录"""
|
||||
# 按文件名分组
|
||||
@@ -166,6 +171,7 @@ async def get_file_history():
|
||||
|
||||
|
||||
@router.get("/api/history/{filename}")
|
||||
@router.post("/api/history/{filename}")
|
||||
async def get_file_records(filename: str):
|
||||
"""获取指定文件名的所有记录"""
|
||||
# URL解码文件名
|
||||
@@ -194,6 +200,7 @@ async def get_file_records(filename: str):
|
||||
|
||||
|
||||
@router.get("/history")
|
||||
@router.post("/history")
|
||||
async def history_page(request: Request):
|
||||
"""历史记录页面"""
|
||||
from fastapi.templating import Jinja2Templates
|
||||
@@ -209,6 +216,7 @@ async def history_page(request: Request):
|
||||
|
||||
|
||||
@router.get("/result/{task_id}")
|
||||
@router.post("/result/{task_id}")
|
||||
async def result_page(request: Request, task_id: str):
|
||||
"""结果详情页面"""
|
||||
if task_id not in tasks:
|
||||
|
||||
@@ -101,6 +101,7 @@ app.include_router(router)
|
||||
|
||||
|
||||
@app.get("/health")
|
||||
@app.post("/health")
|
||||
async def health():
|
||||
from database.database import db_manager
|
||||
return {
|
||||
|
||||
+6
-2
@@ -9,7 +9,9 @@ async function loadHistory() {
|
||||
const fileList = document.getElementById('fileList');
|
||||
|
||||
try {
|
||||
const response = await fetch('/api/history');
|
||||
const response = await fetch('/api/history', {
|
||||
method: 'POST'
|
||||
});
|
||||
if (!response.ok) {
|
||||
throw new Error('获取历史记录失败');
|
||||
}
|
||||
@@ -94,7 +96,9 @@ async function toggleFileRecords(filename) {
|
||||
}
|
||||
|
||||
try {
|
||||
const response = await fetch(`/api/history/${encodeURIComponent(filename)}`);
|
||||
const response = await fetch(`/api/history/${encodeURIComponent(filename)}`, {
|
||||
method: 'POST'
|
||||
});
|
||||
if (!response.ok) {
|
||||
throw new Error('获取记录详情失败');
|
||||
}
|
||||
|
||||
+26
-1
@@ -143,7 +143,9 @@ async function uploadFile() {
|
||||
|
||||
async function pollTaskStatus(taskId) {
|
||||
try {
|
||||
const response = await fetch(`/status/${taskId}`);
|
||||
const response = await fetch(`/status/${taskId}`, {
|
||||
method: 'POST'
|
||||
});
|
||||
const task = await response.json();
|
||||
|
||||
console.log('任务状态:', task.status);
|
||||
@@ -566,6 +568,29 @@ function hideError() {
|
||||
errorMessage.style.display = 'none';
|
||||
}
|
||||
|
||||
// 通过POST请求跳转到历史页面
|
||||
async function goToHistory() {
|
||||
try {
|
||||
const response = await fetch('/history', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
});
|
||||
|
||||
if (response.ok) {
|
||||
// 如果返回的是HTML页面,直接重定向
|
||||
window.location.href = '/history';
|
||||
} else {
|
||||
throw new Error('跳转失败');
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('跳转到历史页面失败:', error);
|
||||
// 如果POST失败,尝试直接GET跳转
|
||||
window.location.href = '/history';
|
||||
}
|
||||
}
|
||||
|
||||
// 添加显示函数
|
||||
function displayCavityData(cavityData) {
|
||||
const cavityDiv = document.getElementById('cavityData');
|
||||
|
||||
@@ -117,7 +117,7 @@
|
||||
<div style="display: flex; justify-content: space-between; align-items: center;">
|
||||
<p>PythonOCC 可用: {{ pythonocc_available }} | 服务版本: 3.0.0</p>
|
||||
<div>
|
||||
<button class="upload-btn" onclick="location.href='/history'" style="background: #666; margin-left: 10px;">
|
||||
<button class="upload-btn" onclick="goToHistory()" style="background: #666; margin-left: 10px;">
|
||||
📋 查看历史记录
|
||||
</button>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user