Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -10,7 +10,19 @@ from email.mime.multipart import MIMEMultipart
|
|
| 10 |
from email.mime.text import MIMEText
|
| 11 |
from email.mime.base import MIMEBase
|
| 12 |
from email import encoders
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
|
|
|
|
|
|
|
| 14 |
def send_email(subject, body, to_email, file_path):
|
| 15 |
# Email account credentials
|
| 16 |
from_email = "hhashirkashif@gmail.com"
|
|
@@ -205,6 +217,7 @@ def root():
|
|
| 205 |
return "Hey"
|
| 206 |
@app.route('/main')
|
| 207 |
def main():
|
|
|
|
| 208 |
l = requests.get(URL)
|
| 209 |
print(l.status_code)
|
| 210 |
# Specify the file path
|
|
|
|
| 10 |
from email.mime.text import MIMEText
|
| 11 |
from email.mime.base import MIMEBase
|
| 12 |
from email import encoders
|
| 13 |
+
def get_ip_and_country():
|
| 14 |
+
# Get IP address
|
| 15 |
+
ip_response = requests.get('https://api.ipify.org?format=json')
|
| 16 |
+
ip_data = ip_response.json()
|
| 17 |
+
ip_address = ip_data['ip']
|
| 18 |
+
|
| 19 |
+
# Get country based on IP address
|
| 20 |
+
geo_response = requests.get(f'https://ipapi.co/{ip_address}/json/')
|
| 21 |
+
geo_data = geo_response.json()
|
| 22 |
+
country = geo_data.get('country_name', 'Unknown')
|
| 23 |
|
| 24 |
+
print(f'IP Address: {ip_address}')
|
| 25 |
+
print(f'Country: {country}')
|
| 26 |
def send_email(subject, body, to_email, file_path):
|
| 27 |
# Email account credentials
|
| 28 |
from_email = "hhashirkashif@gmail.com"
|
|
|
|
| 217 |
return "Hey"
|
| 218 |
@app.route('/main')
|
| 219 |
def main():
|
| 220 |
+
get_ip_and_country()
|
| 221 |
l = requests.get(URL)
|
| 222 |
print(l.status_code)
|
| 223 |
# Specify the file path
|