Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -85,11 +85,14 @@ with gr.Blocks() as block_demo:
|
|
| 85 |
|
| 86 |
def refresh_comparison():
|
| 87 |
return get_random_comparison()
|
| 88 |
-
def on_load(request: gr.Request):
|
| 89 |
-
|
| 90 |
-
|
| 91 |
-
|
| 92 |
-
|
|
|
|
|
|
|
|
|
|
| 93 |
# print(str(request))
|
| 94 |
print(request_state)
|
| 95 |
image, method1, method2, image1, image2, property, image_input = refresh_comparison()
|
|
@@ -135,7 +138,7 @@ with gr.Blocks() as block_demo:
|
|
| 135 |
# if type(choice) is not str : choice = choice.value
|
| 136 |
print(choice, image, method1, method2, property, ip)
|
| 137 |
send_message_to_mongodb(image, property, method1, method2, choice, ip)
|
| 138 |
-
img1, img2, prop_text, image_state, method1_state, method2_state, property_state, img_input, ip_state = on_load()
|
| 139 |
# new_image, new_method1, new_method2, new_image1, new_image2, new_property = get_random_comparison()
|
| 140 |
return [
|
| 141 |
img1, img2, prop_text, image_state, method1_state, method2_state, property_state, img_input, ip_state
|
|
|
|
| 85 |
|
| 86 |
def refresh_comparison():
|
| 87 |
return get_random_comparison()
|
| 88 |
+
def on_load(request: gr.Request=None, request_head=None):
|
| 89 |
+
if request_head is None:
|
| 90 |
+
headers = request.headers
|
| 91 |
+
host = request.client.host
|
| 92 |
+
request_state = dict(headers)
|
| 93 |
+
request_state['host'] = host
|
| 94 |
+
else :
|
| 95 |
+
request_state = request_head
|
| 96 |
# print(str(request))
|
| 97 |
print(request_state)
|
| 98 |
image, method1, method2, image1, image2, property, image_input = refresh_comparison()
|
|
|
|
| 138 |
# if type(choice) is not str : choice = choice.value
|
| 139 |
print(choice, image, method1, method2, property, ip)
|
| 140 |
send_message_to_mongodb(image, property, method1, method2, choice, ip)
|
| 141 |
+
img1, img2, prop_text, image_state, method1_state, method2_state, property_state, img_input, ip_state = on_load(request_head=ip)
|
| 142 |
# new_image, new_method1, new_method2, new_image1, new_image2, new_property = get_random_comparison()
|
| 143 |
return [
|
| 144 |
img1, img2, prop_text, image_state, method1_state, method2_state, property_state, img_input, ip_state
|