rishik1111 commited on
Commit
ef5ff5a
·
1 Parent(s): e64b489

Route Streamlit UI queries to live Railway backend API

Browse files
Files changed (1) hide show
  1. web_ui/index.html +10 -2
web_ui/index.html CHANGED
@@ -945,6 +945,14 @@
945
  });
946
  searchBtn.addEventListener("click", executeSearch);
947
 
 
 
 
 
 
 
 
 
948
  async function executeSearch() {
949
  const text = queryInput.value.trim();
950
  if (!text) return;
@@ -963,7 +971,7 @@
963
  fieldNoteText.textContent = `"${text}"`;
964
 
965
  try {
966
- const response = await fetch("/query", { method: "POST", body: formData });
967
  if (!response.ok) {
968
  const errText = await response.text();
969
  let msg = response.statusText || ("HTTP " + response.status);
@@ -1040,7 +1048,7 @@
1040
  formData.append("cross_lingual", isCrossLingual ? "true" : "false");
1041
 
1042
  try {
1043
- const response = await fetch("/query", { method: "POST", body: formData });
1044
  if (!response.ok) {
1045
  const errText = await response.text();
1046
  let msg = response.statusText || ("HTTP " + response.status);
 
945
  });
946
  searchBtn.addEventListener("click", executeSearch);
947
 
948
+ function getApiUrl(path) {
949
+ const origin = window.location.origin;
950
+ if (origin.includes("streamlit.app") || origin.includes("localhost:8501")) {
951
+ return "https://visionquest-production-0621.up.railway.app" + path;
952
+ }
953
+ return path;
954
+ }
955
+
956
  async function executeSearch() {
957
  const text = queryInput.value.trim();
958
  if (!text) return;
 
971
  fieldNoteText.textContent = `"${text}"`;
972
 
973
  try {
974
+ const response = await fetch(getApiUrl("/query"), { method: "POST", body: formData });
975
  if (!response.ok) {
976
  const errText = await response.text();
977
  let msg = response.statusText || ("HTTP " + response.status);
 
1048
  formData.append("cross_lingual", isCrossLingual ? "true" : "false");
1049
 
1050
  try {
1051
+ const response = await fetch(getApiUrl("/query"), { method: "POST", body: formData });
1052
  if (!response.ok) {
1053
  const errText = await response.text();
1054
  let msg = response.statusText || ("HTTP " + response.status);