Spaces:
Runtime error
Runtime error
tianlong12
commited on
Commit
•
395ec56
1
Parent(s):
fed1648
Update app.py
Browse files
app.py
CHANGED
@@ -9,6 +9,26 @@ app = Flask(__name__)
|
|
9 |
def generate_random_ip():
|
10 |
return f"{random.randint(1,255)}.{random.randint(0,255)}.{random.randint(0,255)}.{random.randint(0,255)}"
|
11 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
def format_openai_response(content, finish_reason=None):
|
13 |
return {
|
14 |
"id": "chatcmpl-123",
|
|
|
9 |
def generate_random_ip():
|
10 |
return f"{random.randint(1,255)}.{random.randint(0,255)}.{random.randint(0,255)}.{random.randint(0,255)}"
|
11 |
|
12 |
+
def generate_user_agent():
|
13 |
+
os_list = ['Windows NT 10.0', 'Windows NT 6.1', 'Mac OS X 10_15_7', 'Ubuntu', 'Linux x86_64']
|
14 |
+
browser_list = ['Chrome', 'Firefox', 'Safari', 'Edge']
|
15 |
+
chrome_version = f"{random.randint(70, 126)}.0.{random.randint(1000, 9999)}.{random.randint(100, 999)}"
|
16 |
+
firefox_version = f"{random.randint(70, 100)}.0"
|
17 |
+
safari_version = f"{random.randint(600, 615)}.{random.randint(1, 9)}.{random.randint(1, 9)}"
|
18 |
+
edge_version = f"{random.randint(80, 100)}.0.{random.randint(1000, 9999)}.{random.randint(100, 999)}"
|
19 |
+
|
20 |
+
os = random.choice(os_list)
|
21 |
+
browser = random.choice(browser_list)
|
22 |
+
|
23 |
+
if browser == 'Chrome':
|
24 |
+
return f"Mozilla/5.0 ({os}) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/{chrome_version} Safari/537.36"
|
25 |
+
elif browser == 'Firefox':
|
26 |
+
return f"Mozilla/5.0 ({os}; rv:{firefox_version}) Gecko/20100101 Firefox/{firefox_version}"
|
27 |
+
elif browser == 'Safari':
|
28 |
+
return f"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/{safari_version} (KHTML, like Gecko) Version/{safari_version.split('.')[0]}.1.2 Safari/{safari_version}"
|
29 |
+
elif browser == 'Edge':
|
30 |
+
return f"Mozilla/5.0 ({os}) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/{edge_version} Safari/537.36 Edg/{edge_version}"
|
31 |
+
|
32 |
def format_openai_response(content, finish_reason=None):
|
33 |
return {
|
34 |
"id": "chatcmpl-123",
|