Spaces:
Sleeping
Sleeping
Create index.html
Browse files- index.html +82 -0
index.html
ADDED
@@ -0,0 +1,82 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<!DOCTYPE html>
|
2 |
+
<html lang="en">
|
3 |
+
<head>
|
4 |
+
<meta charset="UTF-8">
|
5 |
+
<title>Township Business Registration</title>
|
6 |
+
<style>
|
7 |
+
body { font-family: sans-serif; padding: 1rem; max-width: 600px; margin: auto; }
|
8 |
+
input, textarea { width: 100%; margin: 0.5rem 0; padding: 0.5rem; }
|
9 |
+
button { padding: 0.7rem 1.5rem; margin-top: 1rem; }
|
10 |
+
</style>
|
11 |
+
</head>
|
12 |
+
<body>
|
13 |
+
<h1>Register Your Township Business</h1>
|
14 |
+
<form id="register-form">
|
15 |
+
<input type="text" id="name" placeholder="Business Name" required />
|
16 |
+
<textarea id="description" placeholder="Description" required></textarea>
|
17 |
+
<input type="text" id="address" placeholder="Address" required />
|
18 |
+
<input type="text" id="phone" placeholder="Phone" required />
|
19 |
+
<input type="hidden" id="latitude" />
|
20 |
+
<input type="hidden" id="longitude" />
|
21 |
+
<button type="submit">Register Business</button>
|
22 |
+
</form>
|
23 |
+
|
24 |
+
<h2>Find Nearby Businesses</h2>
|
25 |
+
<button onclick="getNearbyBusinesses()">Get Nearby</button>
|
26 |
+
<pre id="output"></pre>
|
27 |
+
|
28 |
+
<script>
|
29 |
+
const mcpUrl = "https://puseletso55-township-mcp-server.hf.space";
|
30 |
+
|
31 |
+
navigator.geolocation.getCurrentPosition(position => {
|
32 |
+
document.getElementById("latitude").value = position.coords.latitude;
|
33 |
+
document.getElementById("longitude").value = position.coords.longitude;
|
34 |
+
});
|
35 |
+
|
36 |
+
document.getElementById("register-form").addEventListener("submit", async (e) => {
|
37 |
+
e.preventDefault();
|
38 |
+
|
39 |
+
const data = {
|
40 |
+
method: "registerBusiness",
|
41 |
+
params: {
|
42 |
+
name: document.getElementById("name").value,
|
43 |
+
description: document.getElementById("description").value,
|
44 |
+
address: document.getElementById("address").value,
|
45 |
+
phone: document.getElementById("phone").value,
|
46 |
+
latitude: document.getElementById("latitude").value,
|
47 |
+
longitude: document.getElementById("longitude").value
|
48 |
+
},
|
49 |
+
id: 1
|
50 |
+
};
|
51 |
+
|
52 |
+
const response = await fetch(mcpUrl, {
|
53 |
+
method: "POST",
|
54 |
+
headers: { "Content-Type": "application/json" },
|
55 |
+
body: JSON.stringify({ data: JSON.stringify(data) })
|
56 |
+
});
|
57 |
+
|
58 |
+
const result = await response.json();
|
59 |
+
alert("Business Registered!\n" + JSON.stringify(result, null, 2));
|
60 |
+
});
|
61 |
+
|
62 |
+
async function getNearbyBusinesses() {
|
63 |
+
const lat = document.getElementById("latitude").value;
|
64 |
+
const lon = document.getElementById("longitude").value;
|
65 |
+
const data = {
|
66 |
+
method: "getNearbyBusinesses",
|
67 |
+
params: { latitude: lat, longitude: lon, radius_km: 15 },
|
68 |
+
id: 2
|
69 |
+
};
|
70 |
+
|
71 |
+
const response = await fetch(mcpUrl, {
|
72 |
+
method: "POST",
|
73 |
+
headers: { "Content-Type": "application/json" },
|
74 |
+
body: JSON.stringify({ data: JSON.stringify(data) })
|
75 |
+
});
|
76 |
+
|
77 |
+
const result = await response.json();
|
78 |
+
document.getElementById("output").textContent = JSON.stringify(result, null, 2);
|
79 |
+
}
|
80 |
+
</script>
|
81 |
+
</body>
|
82 |
+
</html>
|