DmitrMakeev commited on
Commit
d42997f
·
verified ·
1 Parent(s): 7b47fec

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +31 -1
app.py CHANGED
@@ -14,7 +14,7 @@ from urllib.parse import quote
14
  import string
15
  from datetime import datetime
16
  import pytz
17
-
18
  from unidecode import unidecode
19
 
20
  from base import replace_null_with_empty_string
@@ -227,6 +227,36 @@ def initialize_requests():
227
 
228
 
229
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
230
 
231
 
232
 
 
14
  import string
15
  from datetime import datetime
16
  import pytz
17
+ import socket
18
  from unidecode import unidecode
19
 
20
  from base import replace_null_with_empty_string
 
227
 
228
 
229
 
230
+ def get_ip_address():
231
+ # Создаем сокет для получения IP-адреса
232
+ temp_socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
233
+ try:
234
+ # Подключаемся к публичному серверу
235
+ temp_socket.connect(("8.8.8.8", 80))
236
+ ip_address = temp_socket.getsockname()[0]
237
+ finally:
238
+ temp_socket.close()
239
+ return ip_address
240
+
241
+ @app.route('/')
242
+ def index():
243
+ # Получаем IP-адрес и порт
244
+ ip_address = get_ip_address()
245
+ port = 5000 # Порт по умолчанию для Flask
246
+ # Формируем HTML-страницу
247
+ html = f"""
248
+ <html>
249
+ <head>
250
+ <title>Server Info</title>
251
+ </head>
252
+ <body>
253
+ <h1>Server Information</h1>
254
+ <p>IP Address: {ip_address}</p>
255
+ <p>Port: {port}</p>
256
+ </body>
257
+ </html>
258
+ """
259
+ return render_template_string(html)
260
 
261
 
262