@@ -22,13 +22,32 @@ def whatIsMyIp():
2222 return jsonify ({"ip" :request .remote_addr })
2323
2424
25- @app .route ("/" , methods = ["GET" ])
25+ @app .route ("/" , methods = ["GET" , "POST" ])
2626def whatismyip ():
2727 loger .loger (request .remote_addr , request .user_agent , request .base_url )
2828
29- infq = checkIpInfo ((request .remote_addr ))
30- return render_template ("home.html" , ip = request .remote_addr ,country = infq ["country" ] ,
31- city = infq ["city" ] , isp = infq ["isp" ])
29+ if request .method == "POST" :
30+ rqIp = request .form .get ("ip" )
31+
32+ infq = checkIpInfo ((rqIp ))
33+ try :
34+ country , city , isp = infq ["country" ] , infq ["city" ] , infq ["isp" ]
35+ except Exception :
36+ country , city , isp = None , None , None
37+
38+
39+ return render_template ("home.html" , ip = rqIp ,country = country ,
40+ city = city , isp = isp )
41+
42+ else :
43+ infq = checkIpInfo ((request .remote_addr ))
44+ try :
45+ country , city , isp = infq ["country" ] , infq ["city" ] , infq ["isp" ]
46+ except Exception :
47+ country , city , isp = None , None , None
48+
49+ return render_template ("home.html" , ip = request .remote_addr ,country = country ,
50+ city = city , isp = isp )
3251
3352
3453
0 commit comments