Skip to content

Commit 74afcf5

Browse files
committed
Modify port 8000 to dynamic port (0) in class 7 of load_json_argv
1 parent 729f1e1 commit 74afcf5

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

‎questionnaire_unit_test.py‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,8 +165,10 @@ class _07_load_json_argv_with_data_via_localhost_8000_in_fixture(_03_load_json_a
165165

166166
# CAREFUL : localhost not always recognized, better to use 127.0.0.1
167167
# Port 0 can also be used and means to select an arbitrary unused port
168+
# HOST, PORT = "127.0.0.1", 8000
169+
# server_adr = f"http://{HOST}:{PORT}/"
168170
HOST, PORT = "127.0.0.1", 0
169-
server_adr = f"http://{HOST}:{PORT}/"
171+
server_adr = ''
170172
Handler = http.server.SimpleHTTPRequestHandler # Open a HTTP server to access to the current directory
171173
httpd = None
172174

@@ -187,6 +189,10 @@ def HTTPServer_Connection(self):
187189
# Exit the server thread when the main thread terminates
188190
server_thread.daemon = True
189191
server_thread.start()
192+
self.httpd_address, self.httpd_port = self.httpd.server_address
193+
self.httpd_url = f"http://{self.httpd_address}:{self.httpd_port}"
194+
print(f"Server URL = {self.httpd_url}")
195+
self.server_adr = f"http://{self.httpd_address}:{self.httpd_port}/"
190196
print(f"\n\nHTTP Connection to {self.server_adr} in {server_thread.name}", end=' ')
191197

192198
def HTTPServer_Disconnection(self):

0 commit comments

Comments
 (0)