Foydalanuvchi commited on
Commit
dcfdb06
·
1 Parent(s): c3cc7ce

Fix NameError: move http.server imports to global scope

Browse files
Files changed (1) hide show
  1. main.py +2 -4
main.py CHANGED
@@ -20,8 +20,10 @@ import asyncio
20
  import collections
21
  import gc
22
  import time
 
23
  from datetime import datetime, timedelta
24
  from dotenv import load_dotenv
 
25
 
26
  from telegram import Update, InlineKeyboardButton, InlineKeyboardMarkup, constants
27
  from telegram.ext import (
@@ -422,7 +424,6 @@ class HealthCheckHandler(BaseHTTPRequestHandler):
422
 
423
  def run_dummy_server():
424
  try:
425
- from http.server import HTTPServer
426
  server = HTTPServer(("0.0.0.0", 7860), HealthCheckHandler)
427
  server.serve_forever()
428
  except Exception as e:
@@ -449,9 +450,6 @@ def wait_for_internet(host="api.telegram.org", port=443, timeout=60):
449
  return False
450
 
451
  if __name__ == '__main__':
452
- from http.server import BaseHTTPRequestHandler
453
- import threading
454
-
455
  if not TOKEN:
456
  logger.error("TELEGRAM_BOT_TOKEN topilmadi! Iltimos, Secrets bo'limini tekshiring.")
457
  else:
 
20
  import collections
21
  import gc
22
  import time
23
+ import threading
24
  from datetime import datetime, timedelta
25
  from dotenv import load_dotenv
26
+ from http.server import BaseHTTPRequestHandler, HTTPServer
27
 
28
  from telegram import Update, InlineKeyboardButton, InlineKeyboardMarkup, constants
29
  from telegram.ext import (
 
424
 
425
  def run_dummy_server():
426
  try:
 
427
  server = HTTPServer(("0.0.0.0", 7860), HealthCheckHandler)
428
  server.serve_forever()
429
  except Exception as e:
 
450
  return False
451
 
452
  if __name__ == '__main__':
 
 
 
453
  if not TOKEN:
454
  logger.error("TELEGRAM_BOT_TOKEN topilmadi! Iltimos, Secrets bo'limini tekshiring.")
455
  else: