Update app.py
Browse files
app.py
CHANGED
@@ -7,6 +7,7 @@ import string
|
|
7 |
import datetime
|
8 |
from webscout import WEBS
|
9 |
from functools import wraps
|
|
|
10 |
|
11 |
app = Flask(__name__)
|
12 |
|
@@ -204,24 +205,26 @@ def generate_key():
|
|
204 |
return jsonify({'error': str(e)}), 500
|
205 |
else:
|
206 |
return render_template('index.html', plans=PRICING_PLANS)
|
207 |
-
import requests
|
208 |
-
|
209 |
-
def get_public_ip():
|
210 |
-
try:
|
211 |
-
response = requests.get('https://api.ipify.org/?format=json')
|
212 |
-
response.raise_for_status() # Raises a HTTPError if the response status is 4xx, 5xx
|
213 |
-
data = response.json()
|
214 |
-
return data['ip']
|
215 |
-
except requests.exceptions.RequestException as e:
|
216 |
-
print(f"An error occurred: {e}")
|
217 |
-
return None
|
218 |
-
|
219 |
-
#Example usage
|
220 |
-
public_ip = get_public_ip()
|
221 |
-
if public_ip:
|
222 |
-
print(f"Public IP: {public_ip}")
|
223 |
-
else:
|
224 |
-
print("Failed to retrieve public IP.")
|
225 |
-
|
226 |
if __name__ == '__main__':
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
227 |
app.run(debug=True)
|
|
|
7 |
import datetime
|
8 |
from webscout import WEBS
|
9 |
from functools import wraps
|
10 |
+
import request
|
11 |
|
12 |
app = Flask(__name__)
|
13 |
|
|
|
205 |
return jsonify({'error': str(e)}), 500
|
206 |
else:
|
207 |
return render_template('index.html', plans=PRICING_PLANS)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
208 |
if __name__ == '__main__':
|
209 |
+
def get_public_ip():
|
210 |
+
try:
|
211 |
+
response = requests.get('https://api.ipify.org/?format=json')
|
212 |
+
response.raise_for_status() # Raises a HTTPError if the response status is 4xx, 5xx
|
213 |
+
data = response.json()
|
214 |
+
return data['ip']
|
215 |
+
except requests.exceptions.RequestException as e:
|
216 |
+
print(f"An error occurred: {e}")
|
217 |
+
return None
|
218 |
+
except Exception as e:
|
219 |
+
print(f"An unexpected error occurred: {e}")
|
220 |
+
return None
|
221 |
+
|
222 |
+
# Get public IP or use a fallback
|
223 |
+
public_ip = get_public_ip() or 'Fallback_IP'
|
224 |
+
|
225 |
+
if public_ip:
|
226 |
+
print(f"Public IP: {public_ip}")
|
227 |
+
else:
|
228 |
+
print("Failed to retrieve public IP. Using fallback IP.")
|
229 |
+
|
230 |
app.run(debug=True)
|