Integrated Swagger UI into FastAPI application for API documentation.
This commit is contained in:
parent
5e47e2b77a
commit
9fa7f2c199
12
app.py
12
app.py
@ -1,11 +1,21 @@
|
|||||||
from fastapi import FastAPI, File, UploadFile
|
from fastapi import FastAPI, File, UploadFile
|
||||||
import tempfile
|
import tempfile
|
||||||
import os
|
import os
|
||||||
|
from fastapi.openapi.docs import get_swagger_ui_html
|
||||||
|
|
||||||
# Assuming Celery is already set up and imported correctly in the project.
|
# Assuming Celery is already set up and imported correctly in the project.
|
||||||
from tasks import delete_temp_file # Import your Celery task here.
|
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/")
|
@app.post("/uploadfile/")
|
||||||
async def upload_file(file: UploadFile = File(...)):
|
async def upload_file(file: UploadFile = File(...)):
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user