Nikhil0987 commited on
Commit
21dcb99
·
verified ·
1 Parent(s): fd4e6da

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -1
app.py CHANGED
@@ -9,6 +9,7 @@ from langchain.document_loaders import PyPDFLoader
9
  import os
10
  import fitz
11
  from PIL import Image
 
12
 
13
  # Global variables
14
  COUNT, N = 0, 0
@@ -121,7 +122,15 @@ if __name__ == "__main__":
121
  "text" # Define txt
122
  ],
123
  title="PDF-Powered Chatbot"
124
- ).interface.launch(server_port=7861, server_name="0.0.0.0", port_checking_timeout=1) # Short checking timeout - for speed
 
 
 
 
 
 
 
 
125
 
126
 
127
 
 
9
  import os
10
  import fitz
11
  from PIL import Image
12
+ import socket
13
 
14
  # Global variables
15
  COUNT, N = 0, 0
 
122
  "text" # Define txt
123
  ],
124
  title="PDF-Powered Chatbot"
125
+ )
126
+
127
+ def find_free_port():
128
+ with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
129
+ s.bind(('', 0))
130
+ return s.getsockname()[1]
131
+
132
+ free_port = find_free_port()
133
+ interface.launch(server_port=free_port)
134
 
135
 
136