-
Notifications
You must be signed in to change notification settings - Fork 2
/
app.py
29 lines (24 loc) · 889 Bytes
/
app.py
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
import requests
from flask import Flask, render_template, request
from settings import settings
app = Flask(__name__)
@app.route("/", methods=["GET", "POST"])
@app.route("/", methods=["GET", "POST"])
def home():
template = render_template(template_name_or_list="index.html")
if request.method == "POST":
ip_address = request.form.get("ip_data", None)
if ip_address:
response = requests.get(
settings.IP_ADDRESS_API.replace(
"IP_ADDRESS_API_KEY", settings.IP_ADDRESS_API_KEY
).replace("IP_ADDRESS", ip_address)
)
data = response.json()
template = render_template(
template_name_or_list="index.html",
data=data,
ip_address=ip_address,
status=response.status_code,
)
return template