Spaces:
Sleeping
Sleeping
Update frontend.py
Browse files- frontend.py +3 -1
frontend.py
CHANGED
|
@@ -6,7 +6,9 @@ history = []
|
|
| 6 |
|
| 7 |
def calculate(expression):
|
| 8 |
try:
|
| 9 |
-
|
|
|
|
|
|
|
| 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('.')
|