|
1 | 1 | import os |
2 | 2 | import uuid |
3 | 3 | import shutil |
| 4 | +import json # Move from within functions to top level |
4 | 5 | from typing import Dict, List, Optional |
5 | 6 | from dotenv import load_dotenv |
6 | 7 |
|
7 | 8 | # Load environment variables from .env file |
8 | 9 | load_dotenv() |
9 | 10 |
|
10 | 11 | from fastapi import FastAPI, BackgroundTasks, HTTPException |
11 | | -from fastapi.responses import JSONResponse |
| 12 | +from fastapi.responses import JSONResponse, PlainTextResponse # Move from within function to top level |
12 | 13 | from pydantic import BaseModel |
13 | 14 |
|
14 | 15 | from app.prompt_generator import PromptGenerator |
@@ -96,7 +97,6 @@ async def get_project_status(project_id: str): |
96 | 97 | raise HTTPException(status_code=404, detail="Project not found") |
97 | 98 |
|
98 | 99 | # Read status file |
99 | | - import json |
100 | 100 | with open(status_file, 'r') as f: |
101 | 101 | status = json.load(f) |
102 | 102 |
|
@@ -132,7 +132,6 @@ async def mcp_compile_and_fix_rust(request: dict): |
132 | 132 | output_text += f"[filename: {filename}]\n{content}\n\n" |
133 | 133 |
|
134 | 134 | # Return as plain text |
135 | | - from fastapi.responses import PlainTextResponse |
136 | 135 | return PlainTextResponse(content=output_text.strip()) |
137 | 136 | else: |
138 | 137 | # For errors, we can still return JSON |
@@ -298,7 +297,6 @@ async def handle_project_generation( |
298 | 297 |
|
299 | 298 | def save_status(project_dir: str, status: Dict): |
300 | 299 | """Save project status to file""" |
301 | | - import json |
302 | 300 | with open(f"{project_dir}/status.json", 'w') as f: |
303 | 301 | json.dump(status, f) |
304 | 302 |
|
|
0 commit comments