Update doc_maker.py
Browse files7 unmodified lines891011121314151617188 unmodified lines27282930313233343536373839404133 unmodified lines757677787980817 unmodified linesimport uuidimport tempfilerouter = APIRouter(prefix="/api/v1")BASE_URL = "https://pvanand-doc-maker.hf.space/api/v1/"# Use system temp directory for file storageDOCS_DIR = os.path.join(tempfile.gettempdir(), "doc_maker_documents")class DocumentPart(BaseModel):8 unmodified linesdownload_url: Optional[str] = Nonedef get_download_url(file_id: str) -> str:return f"{BASE_URL}download/{file_id}"def get_document_path(doc_id: str) -> str:"""Get the full path for a document file"""os.makedirs(DOCS_DIR, exist_ok=True)return os.path.join(DOCS_DIR, f"{doc_id}.json")def update_document(doc_id: str, page_no: int, content: str) -> Dict:"""Update or create document with new page content"""filepath = get_document_path(doc_id)if os.path.exists(filepath):33 unmodified linesdetail=f"Error updating document: {str(e)}")@router.get("/document/{doc_id}", response_model=Dict)async def get_document(doc_id: str):filepath = get_document_path(doc_id)if not os.path.exists(filepath):7 unmodified lines89101112131415168 unmodified lines2526272829303132333435363733 unmodified lines717273747576777 unmodified linesimport uuidimport tempfilerouter = APIRouter() # Add prefix hereBASE_URL = "https://pvanand-doc-maker.hf.space/api/v1"DOCS_DIR = os.path.join(tempfile.gettempdir(), "doc_maker_documents")class DocumentPart(BaseModel):8 unmodified linesdownload_url: Optional[str] = Nonedef get_download_url(file_id: str) -> str:return f"{BASE_URL}/download/{file_id}"def get_document_path(doc_id: str) -> str:os.makedirs(DOCS_DIR, exist_ok=True)return os.path.join(DOCS_DIR, f"{doc_id}.json")def update_document(doc_id: str, page_no: int, content: str) -> Dict:filepath = get_document_path(doc_id)if os.path.exists(filepath):33 unmodified linesdetail=f"Error updating document: {str(e)}")@router.get("/document/{doc_id}")async def get_document(doc_id: str):filepath = get_document_path(doc_id)if not os.path.exists(filepath):
doc_maker.py+4-8