Update app.py
Browse files
app.py
CHANGED
|
@@ -179,6 +179,26 @@ def get_value_after_question_mark(url):
|
|
| 179 |
value_after_question_mark = ""
|
| 180 |
|
| 181 |
return value_after_question_mark
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 182 |
|
| 183 |
def responsefull(
|
| 184 |
request: gr.Request,prompt, history,selected_option,temperature=0.9, max_new_tokens=700, top_p=0.95, repetition_penalty=1.0,
|
|
|
|
| 179 |
value_after_question_mark = ""
|
| 180 |
|
| 181 |
return value_after_question_mark
|
| 182 |
+
def extract_ip_and_device(headers_obj):
|
| 183 |
+
ip_address = None
|
| 184 |
+
device_info = None
|
| 185 |
+
|
| 186 |
+
# Access the raw headers list
|
| 187 |
+
headers = headers_obj.raw
|
| 188 |
+
|
| 189 |
+
for header in headers:
|
| 190 |
+
if len(header) != 2:
|
| 191 |
+
print(f"Unexpected header format: {header}")
|
| 192 |
+
continue
|
| 193 |
+
|
| 194 |
+
key, value = header
|
| 195 |
+
|
| 196 |
+
if key == b'x-forwarded-for':
|
| 197 |
+
ip_address = value.decode('utf-8')
|
| 198 |
+
elif key == b'user-agent':
|
| 199 |
+
device_info = value.decode('utf-8')
|
| 200 |
+
|
| 201 |
+
return ip_address, device_info
|
| 202 |
|
| 203 |
def responsefull(
|
| 204 |
request: gr.Request,prompt, history,selected_option,temperature=0.9, max_new_tokens=700, top_p=0.95, repetition_penalty=1.0,
|