0Learn commited on
Commit
e500c67
·
verified ·
1 Parent(s): 3f68f5c

Update frontend.py

Browse files
Files changed (1) hide show
  1. frontend.py +3 -1
frontend.py CHANGED
@@ -6,7 +6,9 @@ history = []
6
 
7
  def calculate(expression):
8
  try:
9
- response = requests.post("/calculate", json={"expr": expression})
 
 
10
  if response.status_code == 200:
11
  result = response.json()["result"]
12
  result_str = f"{result:.8f}".rstrip('0').rstrip('.')
 
6
 
7
  def calculate(expression):
8
  try:
9
+ # Use the current page's URL to construct the API endpoint
10
+ api_url = gr.get_url() + "/calculate"
11
+ response = requests.post(api_url, json={"expr": expression})
12
  if response.status_code == 200:
13
  result = response.json()["result"]
14
  result_str = f"{result:.8f}".rstrip('0').rstrip('.')