Dooratre commited on
Commit
66fa0b2
·
verified ·
1 Parent(s): a33fd06

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +47 -32
app.py CHANGED
@@ -1,37 +1,52 @@
1
  import requests
2
  import json
3
 
4
- def call_puter_api():
5
- url = "https://api.puter.com/drivers/call"
6
- headers = {
7
- "Authorization": "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ0IjoicyIsInYiOiIwLjAuMCIsInUiOiJtR3F6M3JWNlIyS3o1Y2M1WVV6SWp3PT0iLCJ1dSI6ImpvS2wycFFSVHpDV3FOTmRkQng5V3c9PSIsImlhdCI6MTc0MjkyOTE4OX0.djVas5YRJX1o99LdLMPF7XkNXgdefsYR3wyya2_2R00",
8
- "Content-Type": "application/json;charset=UTF-8",
9
- "Accept": "*/*",
10
- "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.0.0 Safari/537.36",
11
- "Sec-Ch-Ua": '"Not:A-Brand";v="24", "Chromium";v="134"',
12
- "Sec-Ch-Ua-Platform": "Windows",
13
- "Sec-Ch-Ua-Mobile": "?0",
14
- "Origin": "https://docs.puter.com",
15
- "Referer": "https://docs.puter.com/",
16
- "Accept-Encoding": "gzip, deflate, br",
17
- "Accept-Language": "en-US,en;q=0.9",
18
- }
19
 
20
- payload = {
21
- "interface": "puter-chat-completion",
22
- "driver": "claude",
23
- "method": "complete",
24
- "args": {
25
- "messages": [{"role": "user", "content": "Explain quantum computing in simple terms."}], # Hardcoded message
26
- "model": "claude-3-7-sonnet-latest",
27
- "stream": True,
28
- },
29
- }
30
-
31
- with requests.post(url, headers=headers, json=payload, stream=True) as response:
32
- print(response.text)
33
-
34
 
35
- # Run the API call
36
- if __name__ == "__main__":
37
- call_puter_api()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import requests
2
  import json
3
 
4
+ url = "https://api.puter.com/signup"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5
 
6
+ # Headers (removed problematic ones like `Cookie`, `Sec-*`)
7
+ headers = {
8
+ "Accept-Language": "en-US,en;q=0.9",
9
+ "X-Requested-With": "XMLHttpRequest",
10
+ "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.0.0 Safari/537.36",
11
+ "Accept": "*/*",
12
+ "Content-Type": "application/json",
13
+ "Origin": "https://puter.com",
14
+ "Referer": "https://puter.com/",
15
+ "Connection": "keep-alive"
16
+ }
 
 
 
17
 
18
+ # Data payload
19
+ data = {
20
+ "username": "omarnwrxxxxxegee",
21
+ "email": "[email protected]",
22
+ "password": "1QAZ2wsx34$",
23
+ "send_confirmation_code": True,
24
+ "p102xyzname": ""
25
+ }
26
+
27
+ try:
28
+ # Make the POST request
29
+ response = requests.post(url, headers=headers, json=data)
30
+
31
+ # Check if the response status code indicates success (200-299)
32
+ if response.ok:
33
+ try:
34
+ # Attempt to parse the response as JSON
35
+ json_response = response.json()
36
+ print(f"Status Code: {response.status_code}")
37
+ print("Response (JSON):")
38
+ print(json.dumps(json_response, indent=4)) # Pretty-print JSON
39
+ except ValueError:
40
+ # Fallback if the response is not JSON
41
+ print(f"Status Code: {response.status_code}")
42
+ print("Response (Non-JSON):")
43
+ print(response.text)
44
+ else:
45
+ # Handle non-successful HTTP status codes
46
+ print(f"HTTP Error! Status Code: {response.status_code}")
47
+ print("Response:")
48
+ print(response.text)
49
+
50
+ except requests.exceptions.RequestException as e:
51
+ # Handle network-related errors (e.g., connection issues)
52
+ print(f"Request failed: {e}")