Mr-Help commited on
Commit
ebe4628
ยท
verified ยท
1 Parent(s): 02fccd9

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +21 -19
main.py CHANGED
@@ -1,24 +1,26 @@
1
- import os
2
  import requests
3
 
4
- URL = "https://odoo-demo.binrushd.care/api/auth/token"
5
 
6
- # ูŠูุถู„ ุชุฎุฒูŠู† ุงู„ู‚ูŠู… ุฏูŠ ูƒู…ุชุบูŠุฑุงุช ุจูŠุฆุฉ ุจุฏู„ ู…ุง ุชุชูƒุชุจ ุตุฑูŠุญุฉ ููŠ ุงู„ูƒูˆุฏ
7
- headers = {
8
- "CF-Access-Client-Id": "0491b36d7dcabce5b04f1a53f347bb4e.access",
9
- "CF-Access-Client-Secret": "22152cb41b62393e159daaff7dce433006c3744c5850e6adc15fa3544bb5eb09",
10
- "login": "binrushd.automation@gmail.com",
11
- "password": "BR2025",
12
- "db": "Live_August_25",
13
- }
 
 
 
14
 
15
- try:
16
- resp = requests.get(URL, headers=headers, timeout=20)
17
- resp.raise_for_status() # ูŠุฑู…ูŠ ุงุณุชุซู†ุงุก ู„ูˆ ุงู„ูƒูˆุฏ ู…ุด 2xx
18
- # ุฌุฑู‘ุจ JSON ุฃูˆู„ุงู‹ุŒ ูˆู„ูˆ ูุดู„ ุงุทุจุน ุงู„ู†ุต ุงู„ุฎุงู…
19
  try:
20
- print(resp.json())
21
- except ValueError:
22
- print(resp.text)
23
- except requests.RequestException as e:
24
- print("HTTP error:", e)
 
 
 
 
1
+ from fastapi import FastAPI
2
  import requests
3
 
4
+ app = FastAPI()
5
 
6
+ @app.get("/get-token")
7
+ def get_token():
8
+ URL = "https://odoo-demo.binrushd.care/api/auth/token"
9
+
10
+ headers = {
11
+ "CF-Access-Client-Id": "0491b36d7dcabce5b04f1a53f347bb4e.access",
12
+ "CF-Access-Client-Secret": "22152cb41b62393e159daaff7dce433006c3744c5850e6adc15fa3544bb5eb09",
13
+ "login": "binrushd.automation@gmail.com",
14
+ "password": "BR2025",
15
+ "db": "Live_August_25",
16
+ }
17
 
 
 
 
 
18
  try:
19
+ resp = requests.get(URL, headers=headers, timeout=20)
20
+ resp.raise_for_status()
21
+ try:
22
+ return resp.json()
23
+ except ValueError:
24
+ return {"raw_text": resp.text}
25
+ except requests.RequestException as e:
26
+ return {"error": str(e)}