File size: 1,275 Bytes
b8980a7
21725a9
 
ebe4628
21725a9
ebe4628
 
 
 
 
 
 
 
 
 
 
21725a9
 
ebe4628
b8980a7
 
 
 
 
 
 
 
 
ebe4628
b8980a7
 
 
 
 
 
fecf142
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
from fastapi import FastAPI, Response
import requests

app = FastAPI()

@app.get("/get-token")
def get_token():
    URL = "https://odoo-demo.binrushd.care/api/auth/token"

    headers = {
        "CF-Access-Client-Id":     "0491b36d7dcabce5b04f1a53f347bb4e.access",
        "CF-Access-Client-Secret": "22152cb41b62393e159daaff7dce433006c3744c5850e6adc15fa3544bb5eb09",
        "login":                   "binrushd.automation@gmail.com",
        "password":                "BR2025",
        "db":                      "Live_August_25",
    }

    try:
        resp = requests.get(URL, headers=headers, timeout=20)

        # ู‡ู†ุง ุจู†ุฑุฌุน ู†ูุณ ูƒูˆุฏ ุงู„ุญุงู„ุฉ ุงู„ู„ูŠ ุฑุฌู‘ุนู‡ ุงู„ุณูŠุฑูุฑ ุงู„ุฃุตู„ูŠ
        content_type = resp.headers.get("Content-Type", "application/json")
        return Response(
            content=resp.text,
            status_code=resp.status_code,
            media_type=content_type
        )

    except requests.RequestException as e:
        # ู„ูˆ ุญุตู„ ุฎุทุฃ ููŠ ุงู„ุงุชุตุงู„ ู†ูุณู‡ ุฃูˆ Timeout
        return Response(
            content=str(e),
            status_code=500,
            media_type="text/plain"
        )

@app.get("/ping")
def ping():
    return {"status": "alive", "message": "โœ… API is running!"}