import requests import gradio as gr # Define your userspace proxy dictionaries PROXIES = { 'http': 'socks5h://127.0.0.1:1080', 'https': 'socks5h://127.0.0.1:1080' } def make_secure_api_call(target_url): try: # 'socks5h://' forces DNS queries to happen over the WireGuard peer rather than locally response = requests.get(target_url, proxies=PROXIES, timeout=10) # Safely handle JSON structures or fall back to plaintext presentation try: return response.json() except ValueError: return {"raw_response": response.text} except Exception as e: return {"error": str(e)} # Gradio Web Interface matching Hugging Face setup demo = gr.Interface( fn=make_secure_api_call, # Value points directly to the API endpoint instead of the main landing webpage inputs=gr.Textbox(value="https://ipify.org", label="Target Secure API URL"), outputs="json" ) if __name__ == "__main__": demo.launch(server_name="0.0.0.0", server_port=7860)