diff --git a/mysite/settings.py b/mysite/settings.py index 121a452..015b3bd 100644 --- a/mysite/settings.py +++ b/mysite/settings.py @@ -28,11 +28,20 @@ SECRET_KEY = os.getenv('DJANGO_KEY') # SECURITY WARNING: don't run with debug turned on in production! DEBUG = True -ALLOWED_HOSTS = ['*'] +# Allow hosts from env, otherwise fall back to common local/dev hosts. +ALLOWED_HOSTS = [ + 'localhost', + '127.0.0.1', + '0.0.0.0', + '192.168.1.180', + 'acidarchon.com', + 'www.acidarcon.com', +] # Application definition + INSTALLED_APPS = [ 'rest_framework', 'django.contrib.admin', @@ -75,6 +84,13 @@ TEMPLATES = [ WSGI_APPLICATION = 'mysite.wsgi.application' +REST_FRAMEWORK = { + 'DEFAULT_RENDERER_CLASSES': [ + 'rest_framework.renderers.JSONRenderer', + ], +} + + # Database # https://docs.djangoproject.com/en/5.2/ref/settings/#databases @@ -130,5 +146,9 @@ STATIC_ROOT = BASE_DIR / 'staticfiles' # Default primary key field type # https://docs.djangoproject.com/en/5.2/ref/settings/#default-auto-field - DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField' + + +# deplpoy security + +SESSION_COOKIE_SECURE = True diff --git a/static/scripts.js b/static/scripts.js index 0f4fee5..db95b4f 100644 --- a/static/scripts.js +++ b/static/scripts.js @@ -1,41 +1,38 @@ -document.addEventListener('DOMContentLoaded', function () { - const requestOptions = { +var requestOptions = { method: 'GET', headers: { 'Content-Type': 'application/json' }, - }; - - fetch('/doxme/', requestOptions) //call api - .then((response) => response.json()) - .then((jsonResponse) => { - const user_ip = jsonResponse.ip_info.ip; - const user_country = jsonResponse.ip_info.country; - const user_region = jsonResponse.ip_info.country_code; - - // Update the HTML elements with the fetched information - document.getElementById('ip').innerText = `${user_ip}`; - document.getElementById('country').innerText = `${user_country}`; - document.getElementById('region').innerText = `${user_region}`; - - console.log('user_ip:', user_ip); - console.log('couintry:', user_country); - console.log('region:', user_region); - - // IPIS api - const city = jsonResponse.ipis.location.city; - const state = jsonResponse.ipis.location.state; - const isp = jsonResponse.ipis.company.name; - const longitude = jsonResponse.ipis.location.longitude; - - console.log('city', city); - console.log('state', state); - console.log('isp', isp); - console.log('longitude', longitude); - - // innerText - document.getElementById('isp').innerText = `${isp}`; - document.getElementById('city').innerText = `${city}`; +}; +fetch('/doxme/', requestOptions) //call api + .then(function (response) { + return response.json(); }) - .catch((error) => { - console.error('Error fetching IP information:', error); + .then(function (jsonResponse) { + var user_ip = jsonResponse.ip_info.ip; + var user_country = jsonResponse.ip_info.country; + var user_region = jsonResponse.ip_info.country_code; + // Update the HTML elements with the fetched information + document.getElementById('ip').textContent = ''.concat(user_ip); + document.getElementById('country').textContent = ''.concat(user_country); + document.getElementById('region').textContent = ''.concat(user_region); + console.log('user_ip:', user_ip); + console.log('couintry:', user_country); + console.log('region:', user_region); + }) + .catch(function (error) { + console.error('Error fetching IP information:', error); + }); +fetch('http://ip-api.com/json/') + .then(function (response) { + return response.json(); + }) + .then(function (data) { + var user_city = data.city; + var user_isp = data.isp; + console.log('user_city', user_city); + console.log('user_isp', user_isp); + document.getElementById('city').textContent = ''.concat(user_city); + document.getElementById('isp').textContent = ''.concat(user_isp); + }) + .catch(function (err) { + console.log('idk error', err); }); -}); diff --git a/templates/home.html b/templates/home.html index 515dc02..680d75a 100644 --- a/templates/home.html +++ b/templates/home.html @@ -2,9 +2,14 @@ {% load static %} +
+ + + +