benjamin5607 commited on
Commit
ff04787
ยท
verified ยท
1 Parent(s): 24ecfdc

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +41 -15
app.py CHANGED
@@ -59,7 +59,7 @@ db_json_str = json.dumps(PLACE_DB, ensure_ascii=False)
59
  db_base64 = base64.b64encode(db_json_str.encode('utf-8')).decode('utf-8')
60
 
61
  # ==========================================
62
- # 3. ํ†ตํ•ฉ ํ”„๋ก ํŠธ์—”๋“œ (์ค‘๊ด„ํ˜ธ ์™„์ „ ์ด์Šค์ผ€์ดํ”„ ์™„๋ฃŒ)
63
  # ==========================================
64
  html_code = f"""
65
  <!DOCTYPE html>
@@ -186,7 +186,11 @@ html_code = f"""
186
  }}, function(e) {{ console.log("GPS Denied"); }});
187
  }};
188
 
189
- function selectCountry(c) {{ selectedCountry = c; renderList(); }}
 
 
 
 
190
  function setLanguage(l, el) {{
191
  currentLang = l;
192
  document.querySelectorAll('.lang-btn').forEach(function(b) {{ b.classList.remove('active'); }});
@@ -235,8 +239,10 @@ html_code = f"""
235
 
236
  async function sendChat() {{
237
  const inp = document.getElementById('chat-input');
238
- const msg = inp.value.trim(); if(!msg) return;
239
- addChatMessage(msg, 'user'); inp.value = "";
 
 
240
  chatHistory.push({{ role: "user", content: msg }});
241
  const botMsgDiv = addChatMessage("...", "bot");
242
  const res = await callGroq(chatHistory);
@@ -251,13 +257,17 @@ html_code = f"""
251
 
252
  function addChatMessage(t, s) {{
253
  const box = document.getElementById('chat-messages');
254
- const div = document.createElement('div'); div.className = "msg " + s;
255
- div.innerText = t; box.appendChild(div); box.scrollTop = box.scrollHeight;
 
 
 
256
  return div;
257
  }}
258
 
259
  async function openReview(name, country) {{
260
- const p = PLACE_DB[country].find(function(x) {{ return x.name === name; }}); if(!p) return;
 
261
  document.getElementById('repo-title').innerText = name;
262
  document.getElementById('detail-page').style.transform = 'translateX(0%)';
263
  document.getElementById('loader').style.display = 'flex';
@@ -265,7 +275,11 @@ html_code = f"""
265
  miniMap = L.map('mini-map');
266
  L.tileLayer('https://{{s}}.tile.openstreetmap.org/{{z}}/{{x}}/{{y}}.png').addTo(miniMap);
267
  }}
268
- setTimeout(function() {{ miniMap.invalidateSize(); miniMap.setView([p.lat, p.lon], 15); L.marker([p.lat, p.lon]).addTo(miniMap); }}, 400);
 
 
 
 
269
  const prompt = [
270
  {{ role: "system", content: "Act as Emily. Write review in " + TRANSLATIONS[currentLang].ai + ". Sections: Vibe, Must Try, Secret Tip." }},
271
  {{ role: "user", content: "Write review for " + name + " in " + country }}
@@ -283,11 +297,16 @@ html_code = f"""
283
  body: JSON.stringify({{
284
  model: "llama-3.3-70b-versatile",
285
  messages: messages,
286
- temperature: 0.7, top_p: 0.85, frequency_penalty: 0.7
 
 
287
  }})
288
  }});
289
- const d = await r.json(); return d.choices[0].message.content;
290
- } catch(e) {{ return "Sweetie, the connection is a bit unstable."; }}
 
 
 
291
  }}
292
 
293
  function openMap() {{
@@ -310,17 +329,24 @@ html_code = f"""
310
  if(userLat && userLon) {{
311
  worldMap.flyTo([userLat, userLon], 15);
312
  L.marker([userLat, userLon]).addTo(worldMap).bindPopup("๐Ÿ“ My Spot").openPopup();
313
- }} else {{ alert("GPS off, honey!"); }}
 
 
314
  }}
315
 
316
  function searchAndOpenMap(pName) {{
317
- let found = null; let fCountry = "";
 
318
  Object.keys(PLACE_DB).some(function(c) {{
319
  found = PLACE_DB[c].find(function(p) {{ return p.name.includes(pName); }});
320
  if(found) {{ fCountry = c; return true; }}
 
321
  }});
322
- if(found) {{ window.open(getMapUrl(found, fCountry), '_blank'); }}
323
- else {{ window.open("https://www.google.com/maps/search/" + encodeURIComponent(pName), '_blank'); }}
 
 
 
324
  }}
325
 
326
  function closeMap() {{ document.getElementById('world-map-page').style.transform = 'translateY(100%)'; }}
 
59
  db_base64 = base64.b64encode(db_json_str.encode('utf-8')).decode('utf-8')
60
 
61
  # ==========================================
62
+ # 3. ํ†ตํ•ฉ ํ”„๋ก ํŠธ์—”๋“œ (f-string ์ค‘๊ด„ํ˜ธ ์™„์ „ ์ด์Šค์ผ€์ดํ”„)
63
  # ==========================================
64
  html_code = f"""
65
  <!DOCTYPE html>
 
186
  }}, function(e) {{ console.log("GPS Denied"); }});
187
  }};
188
 
189
+ function selectCountry(c) {{
190
+ selectedCountry = c;
191
+ renderList();
192
+ }}
193
+
194
  function setLanguage(l, el) {{
195
  currentLang = l;
196
  document.querySelectorAll('.lang-btn').forEach(function(b) {{ b.classList.remove('active'); }});
 
239
 
240
  async function sendChat() {{
241
  const inp = document.getElementById('chat-input');
242
+ const msg = inp.value.trim();
243
+ if(!msg) return;
244
+ addChatMessage(msg, 'user');
245
+ inp.value = "";
246
  chatHistory.push({{ role: "user", content: msg }});
247
  const botMsgDiv = addChatMessage("...", "bot");
248
  const res = await callGroq(chatHistory);
 
257
 
258
  function addChatMessage(t, s) {{
259
  const box = document.getElementById('chat-messages');
260
+ const div = document.createElement('div');
261
+ div.className = "msg " + s;
262
+ div.innerText = t;
263
+ box.appendChild(div);
264
+ box.scrollTop = box.scrollHeight;
265
  return div;
266
  }}
267
 
268
  async function openReview(name, country) {{
269
+ const p = PLACE_DB[country].find(function(x) {{ return x.name === name; }});
270
+ if(!p) return;
271
  document.getElementById('repo-title').innerText = name;
272
  document.getElementById('detail-page').style.transform = 'translateX(0%)';
273
  document.getElementById('loader').style.display = 'flex';
 
275
  miniMap = L.map('mini-map');
276
  L.tileLayer('https://{{s}}.tile.openstreetmap.org/{{z}}/{{x}}/{{y}}.png').addTo(miniMap);
277
  }}
278
+ setTimeout(function() {{
279
+ miniMap.invalidateSize();
280
+ miniMap.setView([p.lat, p.lon], 15);
281
+ L.marker([p.lat, p.lon]).addTo(miniMap);
282
+ }}, 400);
283
  const prompt = [
284
  {{ role: "system", content: "Act as Emily. Write review in " + TRANSLATIONS[currentLang].ai + ". Sections: Vibe, Must Try, Secret Tip." }},
285
  {{ role: "user", content: "Write review for " + name + " in " + country }}
 
297
  body: JSON.stringify({{
298
  model: "llama-3.3-70b-versatile",
299
  messages: messages,
300
+ temperature: 0.7,
301
+ top_p: 0.85,
302
+ frequency_penalty: 0.7
303
  }})
304
  }});
305
+ const d = await r.json();
306
+ return d.choices[0].message.content;
307
+ } catch(e) {{
308
+ return "Sweetie, the connection is a bit unstable.";
309
+ }}
310
  }}
311
 
312
  function openMap() {{
 
329
  if(userLat && userLon) {{
330
  worldMap.flyTo([userLat, userLon], 15);
331
  L.marker([userLat, userLon]).addTo(worldMap).bindPopup("๐Ÿ“ My Spot").openPopup();
332
+ }} else {{
333
+ alert("GPS off, honey!");
334
+ }}
335
  }}
336
 
337
  function searchAndOpenMap(pName) {{
338
+ let found = null;
339
+ let fCountry = "";
340
  Object.keys(PLACE_DB).some(function(c) {{
341
  found = PLACE_DB[c].find(function(p) {{ return p.name.includes(pName); }});
342
  if(found) {{ fCountry = c; return true; }}
343
+ return false;
344
  }});
345
+ if(found) {{
346
+ window.open(getMapUrl(found, fCountry), '_blank');
347
+ }} else {{
348
+ window.open("https://www.google.com/maps/search/" + encodeURIComponent(pName), '_blank');
349
+ }}
350
  }}
351
 
352
  function closeMap() {{ document.getElementById('world-map-page').style.transform = 'translateY(100%)'; }}