|  |  | @ -2,12 +2,14 @@ import os | 
			
		
	
		
		
			
				
					
					|  |  |  | import subprocess |  |  |  | import subprocess | 
			
		
	
		
		
			
				
					
					|  |  |  | import re |  |  |  | import re | 
			
		
	
		
		
			
				
					
					|  |  |  | import shutil |  |  |  | import shutil | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | import pyqrcode | 
			
		
	
		
		
			
				
					
					|  |  |  | import time |  |  |  | import time | 
			
		
	
		
		
			
				
					
					|  |  |  | from ..utils.print_markdown import print_markdown |  |  |  | from ..utils.print_markdown import print_markdown | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | def create_tunnel(tunnel_method='ngrok', server_host='localhost', server_port=10001): |  |  |  | def create_tunnel(tunnel_method='ngrok', server_host='localhost', server_port=10001, qr=False): | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |     print_markdown(f"Exposing server to the internet...") |  |  |  |     print_markdown(f"Exposing server to the internet...") | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     server_url = "" | 
			
		
	
		
		
			
				
					
					|  |  |  |     if tunnel_method == "bore": |  |  |  |     if tunnel_method == "bore": | 
			
		
	
		
		
			
				
					
					|  |  |  |         try: |  |  |  |         try: | 
			
		
	
		
		
			
				
					
					|  |  |  |             output = subprocess.check_output('command -v bore', shell=True) |  |  |  |             output = subprocess.check_output('command -v bore', shell=True) | 
			
		
	
	
		
		
			
				
					|  |  | @ -27,6 +29,7 @@ def create_tunnel(tunnel_method='ngrok', server_host='localhost', server_port=10 | 
			
		
	
		
		
			
				
					
					|  |  |  |                 break |  |  |  |                 break | 
			
		
	
		
		
			
				
					
					|  |  |  |             if "listening at bore.pub:" in line: |  |  |  |             if "listening at bore.pub:" in line: | 
			
		
	
		
		
			
				
					
					|  |  |  |                 remote_port = re.search('bore.pub:([0-9]*)', line).group(1) |  |  |  |                 remote_port = re.search('bore.pub:([0-9]*)', line).group(1) | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 server_url = f"bore.pub:{remote_port}" | 
			
		
	
		
		
			
				
					
					|  |  |  |                 print_markdown(f"Your server is being hosted at the following URL: bore.pub:{remote_port}") |  |  |  |                 print_markdown(f"Your server is being hosted at the following URL: bore.pub:{remote_port}") | 
			
		
	
		
		
			
				
					
					|  |  |  |                 break |  |  |  |                 break | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
	
		
		
			
				
					|  |  | @ -53,7 +56,7 @@ def create_tunnel(tunnel_method='ngrok', server_host='localhost', server_port=10 | 
			
		
	
		
		
			
				
					
					|  |  |  |                 if match: |  |  |  |                 if match: | 
			
		
	
		
		
			
				
					
					|  |  |  |                     found_url = True |  |  |  |                     found_url = True | 
			
		
	
		
		
			
				
					
					|  |  |  |                     remote_url = match.group(0).replace('your url is: ', '') |  |  |  |                     remote_url = match.group(0).replace('your url is: ', '') | 
			
		
	
		
		
			
				
					
					|  |  |  |                      |  |  |  |                     server_url = remote_url | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |                     print(f"\nYour server is being hosted at the following URL: {remote_url}") |  |  |  |                     print(f"\nYour server is being hosted at the following URL: {remote_url}") | 
			
		
	
		
		
			
				
					
					|  |  |  |                     break  # Exit the loop once the URL is found |  |  |  |                     break  # Exit the loop once the URL is found | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
	
		
		
			
				
					|  |  | @ -71,7 +74,7 @@ def create_tunnel(tunnel_method='ngrok', server_host='localhost', server_port=10 | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |         # If ngrok is installed, start it on the specified port |  |  |  |         # If ngrok is installed, start it on the specified port | 
			
		
	
		
		
			
				
					
					|  |  |  |         # process = subprocess.Popen(f'ngrok http {server_port} --log=stdout', shell=True, stdout=subprocess.PIPE) |  |  |  |         # process = subprocess.Popen(f'ngrok http {server_port} --log=stdout', shell=True, stdout=subprocess.PIPE) | 
			
		
	
		
		
			
				
					
					|  |  |  |         process = subprocess.Popen(f'ngrok http {server_port} --scheme http,https  --log=stdout', shell=True, stdout=subprocess.PIPE) |  |  |  |         process = subprocess.Popen(f'ngrok http {server_port} --scheme http,https --domain=marten-advanced-dragon.ngrok-free.app --log=stdout', shell=True, stdout=subprocess.PIPE) | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |         # Initially, no URL is found |  |  |  |         # Initially, no URL is found | 
			
		
	
		
		
			
				
					
					|  |  |  |         found_url = False |  |  |  |         found_url = False | 
			
		
	
	
		
		
			
				
					|  |  | @ -87,9 +90,16 @@ def create_tunnel(tunnel_method='ngrok', server_host='localhost', server_port=10 | 
			
		
	
		
		
			
				
					
					|  |  |  |             if match: |  |  |  |             if match: | 
			
		
	
		
		
			
				
					
					|  |  |  |                 found_url = True |  |  |  |                 found_url = True | 
			
		
	
		
		
			
				
					
					|  |  |  |                 remote_url = match.group(0) |  |  |  |                 remote_url = match.group(0) | 
			
		
	
		
		
			
				
					
					|  |  |  |                  |  |  |  |                 server_url = remote_url | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |                 print(f"\nYour server is being hosted at the following URL: {remote_url}") |  |  |  |                 print(f"\nYour server is being hosted at the following URL: {remote_url}") | 
			
		
	
		
		
			
				
					
					|  |  |  |                 break  # Exit the loop once the URL is found |  |  |  |                 break  # Exit the loop once the URL is found | 
			
		
	
		
		
			
				
					
					|  |  |  |          |  |  |  |          | 
			
		
	
		
		
			
				
					
					|  |  |  |         if not found_url: |  |  |  |         if not found_url: | 
			
		
	
		
		
			
				
					
					|  |  |  |             print("Failed to extract the ngrok tunnel URL. Please check ngrok's output for details.") |  |  |  |             print("Failed to extract the ngrok tunnel URL. Please check ngrok's output for details.") | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     if server_url and qr: | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         text = pyqrcode.create(remote_url) | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         print(text.terminal(quiet_zone=1)) | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     return server_url | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
	
		
		
			
				
					|  |  | 
 |