-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
54 lines (41 loc) · 1.42 KB
/
app.py
File metadata and controls
54 lines (41 loc) · 1.42 KB
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
53
54
from fastapi import FastAPI
from functions import *
from fastapi.middleware.cors import CORSMiddleware
app = FastAPI(docs_url='/api/documentation', title="Flarion Development INC.", description="Flarion Development INC. API", version="1.0.0")
origins = [
"http://localhost:8000",
]
# Add CORS middleware
app.add_middleware(
CORSMiddleware,
allow_origins=origins, # Allows all origins
allow_credentials=True,
allow_methods=["*"], # Allows all methods
allow_headers=["*"], # Allows all headers
)
@app.get("/")
async def index():
return {
"message": "Flarion Development INC.!",
"status": "API Aktif!",
}
@app.get("/phone/{phonenumber}/{country}")
async def phone_info(phonenumber: str, country: str):
phone = Phone()
phone.set_phone_number(phonenumber)
phone.set_country_code(country)
is_number_valid,is_possible_number,number_type,isp=get_phone_info(phone.phonenumber, phone.country_code)
return {
"phone_number": phone.phonenumber,
"country_code": phone.country_code,
"is_number_valid": is_number_valid,
"is_possible_number": is_possible_number,
"number_type": number_type,
"isp": isp
}
@app.get("/phone/{phonenumber}")
async def without_country_phone_info(phonenumber: str):
phone = Phone()
phone.set_phone_number(phonenumber)
response = dummy_get_phone_info(phone.phonenumber)
return response