Files
sever-loked/calculator.py
T
2026-03-25 04:35:20 +04:00

43 lines
1.3 KiB
Python

import requests
import sys
import getpass # This hides the password as you type
def start_calculator():
print("\n--- Calculator Unlocked ---")
try:
num1 = float(input("Enter first number: "))
op = input("Enter operator (+, -, *, /): ")
num2 = float(input("Enter second number: "))
# ... (rest of your math logic)
print(f"Result: {num1 + num2}") # Simplified example
except Exception as e:
print(f"Error: {e}")
def check_server():
url = "http://10.0.0.119:6000/status"
print("--- Server Authentication ---")
password = getpass.getpass("Enter Server Password: ")
try:
# Send the password in the headers
headers = {'x-password': password}
response = requests.get(url, headers=headers)
if response.status_code == 200:
data = response.json()
if data.get("run") == "yes":
start_calculator()
else:
print("Server is set to 'no'. Access denied.")
elif response.status_code == 401:
print("Access Denied: Incorrect Password.")
else:
print(f"Server returned status code: {response.status_code}")
except requests.exceptions.ConnectionError:
print("Could not connect to server.")
if __name__ == "__main__":
check_server()