suryanshp1 commited on
Commit
a86f21e
·
verified ·
1 Parent(s): 9812f28

Upload 2 files

Browse files
Files changed (2) hide show
  1. Dockerfile +3 -0
  2. app.py +24 -2
Dockerfile CHANGED
@@ -44,5 +44,8 @@ ENV GROQ_API_KEY1=$GROQ_API_KEY1 \
44
  CLOUDINARY_API_SECRET=$CLOUDINARY_API_SECRET \
45
  LOG_DIR=/app/logs
46
 
 
 
 
47
  # Set the default command
48
  CMD ["python", "-u", "app.py"]
 
44
  CLOUDINARY_API_SECRET=$CLOUDINARY_API_SECRET \
45
  LOG_DIR=/app/logs
46
 
47
+ # Expose the required port
48
+ EXPOSE 7860
49
+
50
  # Set the default command
51
  CMD ["python", "-u", "app.py"]
app.py CHANGED
@@ -25,6 +25,8 @@ import schedule
25
  import markdown2
26
  import ast
27
  from logging.handlers import RotatingFileHandler
 
 
28
 
29
  load_dotenv()
30
 
@@ -901,7 +903,7 @@ def main():
901
 
902
  schedule.run_pending()
903
 
904
- time.sleep(12) # Adjust the sleep duration as needed
905
 
906
  except KeyboardInterrupt as e:
907
  bot.stop()
@@ -910,5 +912,25 @@ def main():
910
  bot.stop()
911
  logger.exception(f"Error in main (): {e} | Traceback: {traceback.format_exc()}")
912
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
913
  if __name__ == "__main__":
914
- main()
 
 
 
 
 
 
 
25
  import markdown2
26
  import ast
27
  from logging.handlers import RotatingFileHandler
28
+ from http.server import SimpleHTTPRequestHandler, HTTPServer
29
+ from threading import Thread
30
 
31
  load_dotenv()
32
 
 
903
 
904
  schedule.run_pending()
905
 
906
+ time.sleep(5) # Adjust the sleep duration as needed
907
 
908
  except KeyboardInterrupt as e:
909
  bot.stop()
 
912
  bot.stop()
913
  logger.exception(f"Error in main (): {e} | Traceback: {traceback.format_exc()}")
914
 
915
+ # HTTP server
916
+ class MyHandler(SimpleHTTPRequestHandler):
917
+ def do_GET(self):
918
+ # Respond with a simple message
919
+ self.send_response(200)
920
+ self.send_header("Content-type", "text/plain")
921
+ self.end_headers()
922
+ self.wfile.write(b"The bot is running on port 7860")
923
+
924
+ def run_http_server():
925
+ server = HTTPServer(('', 7860), MyHandler)
926
+ print("HTTP server is running on port 7860")
927
+ server.serve_forever()
928
+
929
  if __name__ == "__main__":
930
+ # main()
931
+ # Start the bot in a separate thread
932
+ bot_thread = Thread(target=main, daemon=True)
933
+ bot_thread.start()
934
+
935
+ # Start the HTTP server in the main thread
936
+ run_http_server()