Spaces:
Paused
Paused
| import requests | |
| import gzip | |
| import shutil | |
| import subprocess | |
| import os | |
| # URL of the .gz file | |
| url = "https://github.com/jpillora/chisel/releases/download/v1.10.1/chisel_1.10.1_linux_amd64.gz" | |
| file_name = "chisel_1.10.1_linux_amd64.gz" | |
| output_file = "chisel" | |
| # Download the .gz file | |
| response = requests.get(url, stream=True) | |
| with open(file_name, 'wb') as f: | |
| shutil.copyfileobj(response.raw, f) | |
| print(f"Downloaded {file_name}") | |
| # Extract the .gz file | |
| with gzip.open(file_name, 'rb') as f_in: | |
| with open(output_file, 'wb') as f_out: | |
| shutil.copyfileobj(f_in, f_out) | |
| # Make the file executable | |
| os.chmod(output_file, 0o755) | |
| print(f"Extracted {output_file}") | |
| # Start chisel server in the background | |
| def start_chisel(): | |
| try: | |
| os.system(f"./{output_file} server --host 0.0.0.0 --port 7860" --proxy http://127.0.0.1:8188 --reverse) | |
| print("Chisel server started successfully.") | |
| except Exception as e: | |
| print(f"Failed to start chisel server: {e}") | |
| # Run chisel in the background | |
| start_chisel() | |