| | from fastapi import FastAPI, HTTPException, Response
|
| | from pydantic import BaseModel
|
| | from plantuml import PlantUML
|
| |
|
| | app = FastAPI()
|
| |
|
| | class PlantUMLRequest(BaseModel):
|
| | script: str
|
| |
|
| |
|
| | plantuml_server = PlantUML(url="http://www.plantuml.com/plantuml/png/")
|
| |
|
| | @app.post("/generate-image/")
|
| | async def generate_image(request: PlantUMLRequest):
|
| | try:
|
| |
|
| | image_data = plantuml_server.processes(request.script)
|
| | return Response(content=image_data, media_type="image/png")
|
| | except Exception as e:
|
| | raise HTTPException(status_code=500, detail=str(e))
|
| |
|