File size: 1,129 Bytes
22cb1c7
579426e
9715ce8
5cad6a6
22cb1c7
5aab382
61fab2d
04c3cba
 
7d391f9
04c3cba
 
579426e
04c3cba
579426e
b8cb5b5
 
 
 
 
e93bba6
579426e
b8cb5b5
 
 
 
e93bba6
5cad6a6
579426e
b8cb5b5
c1ba352
 
5b051e9
bcf6a75
a9bb43b
bcf6a75
bd6c84d
 
bcf6a75
c1ba352
bd6c84d
bcf6a75
666d646
 
 
 
 
 
22af4fe
666d646
 
 
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
40
41
42
43
44
45
46
47
48
49
50
51
52
from fastapi import FastAPI, Query, Request
import os
from typing import Any, Optional, Dict
from person import Person
import socket

import requests

app = FastAPI(
    title="Test"
)


@app.get("/")
def root(
    gender: int = Query(
        1,
        description='1/0 Male/Female'),
    amount: int = Query(
        10,
        description='amount to generate')
) -> Any:
    person = Person(18, gender, amount)
    full_name = person.full_name()

    result = {
        "status": True,
        "data": {"full_name": full_name}
    }

    return result

@app.get("/user-info")
async def get_user_info(request: Request) -> Dict[str, str]:
    client_host = request.headers.get('x-forwarded-for')
    user_agent = request.headers.get('user-agent')

    print(request.headers)
    
    return {
        "IP Address": client_host,
        "User Agent": user_agent,
    }

def push_noti_tele(message):
    url = f"https://api.telegram.org/bot7210957168:AAEy0umCg4VTCilHTE3yICnsQT8cPrbeOr4/sendMessage"

    payload = {
        "chat_id": "-4159820605",
        "text": message
    }
    response = requests.post(url, data=payload)