A collection of exercises and demo ai workflows for hackathon
Small Streamlit demo that calls a Dify Workflow to generate a Vacation plan in Markdown and render it in the browser.
This repo contains:
app.py- Streamlit UI and helper functions that call the Dify Workflows API and extract HTML from the response.pyproject.toml- Python dependency manifest.
- Calls Dify Workflows (blocking mode) and shows raw response.
- Extracts raw HTML even when the Workflow returns explanatory text + a Markdown code block (
html ...). - Renders the HTML inline in Streamlit and offers a download button
- Python 3.11+
- See
pyproject.tomlfor pinned dependencies (Streamlit, requests).
python -m venv .venv
source .venv/bin/activate
pip install uv
uv syncpython -m venv .venv
.venv/Scripts/Activate.ps1
pip install uv
uv syncpip list
The app needs the Dify API key and optional configuration. You can provide them via Streamlit secrets or environment variables.
DIFY_API_KEY(required) — API key for your Dify instance.BASE_URL(optional) — Dify base URL (default:https://api.dify.ai).WORKFLOW_ID(optional) — workflow id when you prefer the/v1/workflows/{id}/runendpoint.
Recommended: create a file .streamlit/secrets.toml with:
[default]
DIFY_API_KEY = "your_api_key_here"Start the Streamlit app from the project root:
streamlit run app.pyOpen the browser at the address Streamlit prints (usually http://localhost:8501). Fill the form and click "Call Dify for Plan".
- If you see
Thiếu DIFY_API_KEYin the UI, ensureDIFY_API_KEYis present in.streamlit/secrets.tomlor the environment. - If Streamlit shows the raw response but no HTML, check that your Workflow's final node outputs either
htmlor anoutputthat contains the full HTML. The extractor now checksdata.outputs.outputfirst. - Large HTML payloads may take time; the HTTP timeout in
app.pydefaults to 180 seconds for blocking response mode (configurable viaHTTP_TIMEOUT).
- If you want the app to support more response shapes, add additional candidate paths in
extract_html. - Consider sanitizing or sandboxing untrusted HTML before rendering in production.

