Integrated Swagger UI into FastAPI application for API documentation.

This commit is contained in:
Timothy Farrell (aider) 2024-07-15 17:13:05 -05:00
parent 5e47e2b77a
commit 9fa7f2c199
2 changed files with 11 additions and 1 deletions

12
app.py
View File

@ -1,11 +1,21 @@
from fastapi import FastAPI, File, UploadFile
import tempfile
import os
from fastapi.openapi.docs import get_swagger_ui_html
# Assuming Celery is already set up and imported correctly in the project.
from tasks import delete_temp_file # Import your Celery task here.
app = FastAPI()
app = FastAPI(
title="AI TIST API",
description="This is a simple API for AI TIST.",
version="1.0.0",
docs_url="/docs", # Enable Swagger UI
)
@app.get("/docs")
async def custom_swagger_ui_html():
return get_swagger_ui_html(openapi_url=app.openapi_url, title=app.title + " - Swagger UI")
@app.post("/uploadfile/")
async def upload_file(file: UploadFile = File(...)):