BrandMint Academy
AI basics aayke maadi, guided learning mattu mentoring nodi.
AI Campus • Sahaayaka resources
Connect a real browser form to a Python API and an allowlisted tool before adding an AI agent.
Beginner · 60–120 minutes
Cost: Python standard library only. Runs locally without API keys or cloud hosting.
The ZIP includes the Python code, a README, sample files where needed, and a check you can run. No API key or paid service is needed for this baseline.
Download starter ZIPExtract the ZIP, open its folder in a terminal and follow README.md. Start with python test_starter.py.
Download tool_web_app.py and save it in a new project folder. No pip installation or API key is needed.
Run python tool_web_app.py. Open http://127.0.0.1:8766 in your browser; do not open the Python file itself in the browser.
Choose Word count and submit “hello AI campus”. Expect words=3 and a trace naming count_words. Follow the fetch request in the browser Network panel and inspect the JSON response.
Submit empty text: expect an error. Change the action to First sentence: the output should identify a different tool. Only the two defined tools are allowed.
Once the UI/API baseline works, optionally connect an explicitly local model or an official LangGraph template. Keep tool selection validated on the server and label model errors clearly.
Record a screen demo and commit the source and README. This loopback development server is not a production host; use a framework deployment guide before making a public service.
import argparse
import json
from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer
HTML = """<!doctype html><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1"><title>Local tool web app</title>
<main style="max-width:650px;margin:3rem auto;padding:1rem;font:18px system-ui"><h1>Local tool web app</h1><p>A deterministic tool baseline, without a model or API key.</p>
<form id="form"><label for="action">Tool</label><select id="action"><option value="count_words">Word count</option><option value="first_sentence">First sentence</option></select>
<p><label for="text">Your text</label><br><textarea id="text" required rows="6" style="width:100%"></textarea></p><button>Run tool</button></form><pre id="output" role="status" style="white-space:pre-wrap"></pre></main>
<script>document.querySelector('#form').addEventListener('submit',async event=>{event.preventDefault();const output=document.querySelector('#output');output.textContent='Running…';try{const response=await fetch('/api/run',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({action:document.querySelector('#action').value,text:document.querySelector('#text').value})});output.textContent=JSON.stringify(await response.json(),null,2);}catch{output.textContent='Request failed. Check that the local Python server is running.';}});</script>"""
def run_tool(action, text):
if not isinstance(text, str) or not text.strip() or len(text) > 2000:
raise ValueError("Enter 1–2000 characters of text.")
tools = {"count_words": lambda value: {"words": len(value.split())}, "first_sentence": lambda value: {"sentence": value.strip().split(".")[0]}}
if action not in tools:
raise ValueError("Choose an allowed tool.")
return {"tool": action, "result": tools[action](text), "trace": ["validated input", action, "returned result"]}
class Handler(BaseHTTPRequestHandler):
def reply(self, status, data):
body = json.dumps(data).encode("utf-8")
self.send_response(status)
self.send_header("Content-Type", "application/json; charset=utf-8")
self.send_header("Content-Length", str(len(body)))
self.end_headers()
self.wfile.write(body)
def do_GET(self):
if self.path != "/":
return self.reply(404, {"error": "Not found"})
body = HTML.encode("utf-8")
self.send_response(200)
self.send_header("Content-Type", "text/html; charset=utf-8")
self.send_header("Content-Length", str(len(body)))
self.end_headers()
self.wfile.write(body)
def do_POST(self):
if self.path != "/api/run":
return self.reply(404, {"error": "Not found"})
try:
length = int(self.headers.get("Content-Length", "0"))
if not 0 < length <= 8192:
raise ValueError("Request must be 1–8192 bytes.")
data = json.loads(self.rfile.read(length))
if not isinstance(data, dict):
raise ValueError("Send a JSON object.")
return self.reply(200, run_tool(data.get("action"), data.get("text")))
except (ValueError, TypeError, UnicodeError):
return self.reply(400, {"error": "Check the JSON, allowed tool and non-empty text (up to 2000 characters)."})
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument("--port", type=int, default=8766)
args = parser.parse_args()
print(f"Open http://127.0.0.1:{args.port}", flush=True)
try:
ThreadingHTTPServer(("127.0.0.1", args.port), Handler).serve_forever()
except KeyboardInterrupt:
print("Server stopped.")
python tool_web_app.py
# Open http://127.0.0.1:8766 in your browserA working form sends JSON to /api/run and displays the selected tool, result and trace. “hello AI campus” returns words=3.
This is a deterministic UI/API/tool baseline, not an autonomous or LLM-powered agent. The development server is local only; production hosting, authentication and model access are separate extensions.
BrandMint AI jothe kaliyiri mattu kattiri
AI Campus nalli suddi, tools mattu skills tiliyiri. Mundina kalikege BrandMint AI courses, mentoring athava apps aayke maadi.
AI Campus guides uchita. Course fees mattu labhyatege aayaa platform vivara nodi.
AI basics athava practical software skills kaliyiri.
AI basics aayke maadi, guided learning mattu mentoring nodi.
AI sahayadinda websites mattu applications kattuva daari kaliyiri.
WhatsLearn athava CBSE learning application tereyiri.
WhatsLearn learning application jothe practice munduvarisi.
CBSE vidyarthigalige academic learning sahaya nodi.
Creative practical learning jothe portfolio kattiri.
AI jothe practical marketing kelasa maadi portfolio kattiri.
AI workflow jothe kathe, storyboard mattu short-film portfolio tayaarisi.
Essential cookies site kelasa maadalu beku. Bhaashe mattu subscription aaykegalu nimma device nalli ulitaave. Optional analytics athava advertising cookies eega balasuttilla.
Vivara mattu settings