Как вернуть документ/файл Word в Fastapi? [дубликат] ⇐ Python
-
Гость
Как вернуть документ/файл Word в Fastapi? [дубликат]
Im trying to build an endpoint with GET requests, that only return a word document in my local . but it's working , it keep give me "Internal Server Error". sorry I'm new to fastapi i don't know how to debug the error.
here is what I tried :
@app.get("/file/uploadndownload") def upload_n_downloadfile(): word_document_path = "C:\\Users\\Yaz\\Desktop\\" SAVE_FILE_PATH = os.path.join(word_document_path, "documentation") # Return the Word document as a response return FileResponse( path=SAVE_FILE_PATH, filename="documentation", media_type="application/vnd.openxmlformats-officedocument.wordprocessingml.document")
Источник: https://stackoverflow.com/questions/781 ... in-fastapi
Im trying to build an endpoint with GET requests, that only return a word document in my local . but it's working , it keep give me "Internal Server Error". sorry I'm new to fastapi i don't know how to debug the error.
here is what I tried :
@app.get("/file/uploadndownload") def upload_n_downloadfile(): word_document_path = "C:\\Users\\Yaz\\Desktop\\" SAVE_FILE_PATH = os.path.join(word_document_path, "documentation") # Return the Word document as a response return FileResponse( path=SAVE_FILE_PATH, filename="documentation", media_type="application/vnd.openxmlformats-officedocument.wordprocessingml.document")
Источник: https://stackoverflow.com/questions/781 ... in-fastapi