Spaces:
Sleeping
Sleeping
done and tested
Browse files- app.py +18 -9
- flagged/log.csv +4 -0
app.py
CHANGED
|
@@ -1,16 +1,25 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
import json
|
| 3 |
|
|
|
|
|
|
|
| 4 |
def echo(text, request: gr.Request):
|
| 5 |
-
output_text =
|
| 6 |
if request:
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
print("Query parameters:", dict(request.query_params))
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
|
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
import json
|
| 3 |
|
| 4 |
+
DEBUG_MODE = True
|
| 5 |
+
|
| 6 |
def echo(text, request: gr.Request):
|
| 7 |
+
output_text = {"text": text} # Initialize as a dictionary
|
| 8 |
if request:
|
| 9 |
+
if DEBUG_MODE:
|
| 10 |
+
print("Request object:", request)
|
| 11 |
+
print("Request headers dictionary:", request.headers)
|
| 12 |
+
print("IP address:", request.client.host)
|
| 13 |
+
print("Query parameters:", dict(request.query_params))
|
| 14 |
+
# Convert headers to a dictionary and include them in the output_text
|
| 15 |
+
output_text["headers"] = dict(request.headers.items())
|
| 16 |
+
output_text["host"] = request.client.host
|
| 17 |
+
output_text["query_params"] = dict(request.query_params)
|
| 18 |
+
if DEBUG_MODE:
|
| 19 |
print("Query parameters:", dict(request.query_params))
|
| 20 |
+
|
| 21 |
+
# Convert the output_text dictionary to a JSON-formatted string
|
| 22 |
+
output_text_json = json.dumps(output_text)
|
| 23 |
+
return output_text_json
|
| 24 |
|
| 25 |
+
io = gr.Interface(echo, "textbox", "json").launch(share=True)
|
flagged/log.csv
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
text,output,flag,username,timestamp
|
| 2 |
+
asas,,,,2024-03-08 11:14:29.724973
|
| 3 |
+
asas,,,,2024-03-08 11:14:32.403973
|
| 4 |
+
zcvxc,,,,2024-03-08 11:27:37.358751
|