⚡ Live Interactive Code Sandbox: AI Dev Tool: Show HN Reladraw
▶️ Run Code
💳 Unlock Source Code ($5)
📝 Editable Code Sandbox
```python # AI Dev Tool: Excalidraw Diagram Agent # ====================================== import os import json from typing import Dict, List from fastapi import FastAPI, Request from fastapi.responses import JSONResponse from pydantic import BaseModel from excalidraw import Excalidraw # Define the Excalidraw diagram agent model class DiagramAgent(BaseModel): """Excalidraw diagram agent model""" id: str name: str elements: List[Dict] # Initialize the FastAPI application app = FastAPI() # Load the Excalidraw diagram agent configuration with open('config.json') as f: config = json.load(f) # Define the Excalidraw diagram agent instance excalidraw = Excalidraw(config['excalidraw_url']) # Define the API endpoint to create a new diagram @app.post("/diagrams") async def create_diagram(request: Request): """ Create a new Excalidraw diagram. Returns: JSONResponse: The created diagram ID. """ try: # Create a new Excalidraw diagram diagram_id = excalidraw.create_diagram()
🖥️ Interactive Execution Terminal Console
⚡ Ready! Click ▶️ Run Code to execute code in browser terminal...