added ipinfo.is api , fixed innertext on html
This commit is contained in:
+2
-18
@@ -26,9 +26,9 @@ load_dotenv()
|
||||
SECRET_KEY = os.getenv('DJANGO_KEY')
|
||||
|
||||
# SECURITY WARNING: don't run with debug turned on in production!
|
||||
DEBUG = False
|
||||
DEBUG = True
|
||||
|
||||
ALLOWED_HOSTS = ['localhost']
|
||||
ALLOWED_HOSTS = ['*']
|
||||
|
||||
|
||||
# Application definition
|
||||
@@ -133,19 +133,3 @@ STATIC_ROOT = BASE_DIR / 'staticfiles'
|
||||
|
||||
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
|
||||
|
||||
|
||||
|
||||
# Security settings for production
|
||||
SECURE_SSL_REDIRECT = False
|
||||
USE_TLS = False
|
||||
SECURE_BROWSER_XSS_FILTER = True
|
||||
SECURE_CONTENT_TYPE_NOSNIFF = True
|
||||
CSRF_COOKIE_SECURE = True
|
||||
SESSION_COOKIE_SECURE = True
|
||||
|
||||
|
||||
REST_FRAMEWORK = {
|
||||
'DEFAULT_RENDERER_CLASSES': [
|
||||
'rest_framework.renderers.JSONRenderer',
|
||||
],
|
||||
}
|
||||
|
||||
+11
-6
@@ -31,11 +31,16 @@ class Doxme(APIView):
|
||||
def get(self, request):
|
||||
client_ip = self.get_client_ip(request)
|
||||
|
||||
token = os.getenv('TOKEN')
|
||||
url = f'http://api.ipinfo.io/lite/{client_ip}?token={token}'
|
||||
ip_info = requests.get(url)
|
||||
ipinfo_token = os.getenv('IPINFO_TOKEN')
|
||||
ipinfo_url = f'http://api.ipinfo.io/lite/{client_ip}?token={ipinfo_token}'
|
||||
ip_info = requests.get(ipinfo_url)
|
||||
|
||||
if ip_info.ok and not ip_info.json().get('bogon'):
|
||||
print(ip_info)
|
||||
return Response({'method': 'get', 'ip_info': ip_info.json()}, status=status.HTTP_200_OK)
|
||||
|
||||
ipis_token = os.getenv('IPIS_TOKEN')
|
||||
ipis_url = f'https://api.ipapi.is?q={client_ip}&key={ipis_token}'
|
||||
ipis_info = requests.get(ipis_url)
|
||||
|
||||
if ip_info.ok or ipis_info.ok:
|
||||
print('ipinfo:',ip_info)
|
||||
return Response({'method': 'get', 'ip_info': ip_info.json(),'ipis':ipis_info.json()}, status=status.HTTP_200_OK)
|
||||
return Response({'message': 'error at ipinfo'}, status=status.HTTP_400_BAD_REQUEST)
|
||||
|
||||
Reference in New Issue
Block a user