Spaces:
Sleeping
Sleeping
| import gradio as gr | |
| import requests | |
| import json | |
| API_URL = "https://cloud.flowiseai.com/" | |
| TOKEN = "Bearer qHBaan1Rq3ey80fHiJp5qq-ql65wrDveH327sRjIRoQ" | |
| def call_flowise_api(action, id_or_key, body): | |
| headers = {"Authorization": TOKEN} | |
| endpoint = f"{API_URL}/chatflows" | |
| try: | |
| if action == "list": | |
| response = requests.get(endpoint, headers=headers) | |
| elif action == "get": | |
| response = requests.get(f"{endpoint}/{id_or_key}", headers=headers) | |
| elif action == "create": | |
| response = requests.post(endpoint, headers=headers, json=json.loads(body)) | |
| elif action == "update": | |
| response = requests.put(f"{endpoint}/{id_or_key}", headers=headers, json=json.loads(body)) | |
| elif action == "delete": | |
| response = requests.delete(f"{endpoint}/{id_or_key}", headers=headers) | |
| elif action == "get_by_apikey": | |
| response = requests.get(f"{endpoint}/apikey/{id_or_key}", headers=headers) | |
| else: | |
| return f"Unknown action: {action}", "" | |
| return f"Status Code: {response.status_code}", response.text | |
| except Exception as e: | |
| return "Error", str(e) | |
| with gr.Blocks() as demo: | |
| gr.Markdown("## 🛠️ Flowise Chatflow API Debugger") | |
| action = gr.Dropdown( | |
| ["list", "get", "create", "update", "delete", "get_by_apikey"], | |
| label="Action" | |
| ) | |
| id_or_key = gr.Textbox(label="Chatflow ID or API Key") | |
| body = gr.Textbox(label="JSON Body", lines=10, placeholder='{"name": "Test Flow"}') | |
| status_output = gr.Textbox(label="Status", interactive=False) | |
| response_output = gr.Textbox(label="Response", lines=15, interactive=False) | |
| run_button = gr.Button("Run") | |
| run_button.click(fn=call_flowise_api, inputs=[action, id_or_key, body], outputs=[status_output, response_output]) | |
| gr.app(demo, mcp=True) | |