Peer to Peer code along with test script (#18)

* Initial Peer service code

* Updated peer service

* Updated peer service

* Updated file service

* Updated User Ip registration

* Updated File moving function

* test

* test1 again

* new

---------

Co-authored-by: Sahej Panag <spanag3@gatech.edu>
This commit is contained in:
Aman Tahiliani
2024-04-22 00:42:08 -04:00
committed by GitHub
parent 56318a74da
commit 094a8d763f
7 changed files with 170 additions and 3 deletions

View File

@@ -66,7 +66,13 @@ class PollOnlineView(APIView):
def post(self, request):
try:
user = request.user
ip_address = get_client_ip(request)
try:
data = request.data
ip_address = data['ip']
print("Local IP found in request")
except Exception as e:
ip_address = get_client_ip(request)
print("Using public IP")
user.ip_address = ip_address
user.last_poll = timezone.now()
user.save()

View File

@@ -13,7 +13,13 @@ def get_client_ip(request):
def update_user_ip(request):
user = request.user
ip_address = get_client_ip(request)
try:
data = request.data
ip_address = data['ip']
print("Local IP found in request")
except Exception as e:
ip_address = get_client_ip(request)
print("Using public IP")
user.ip_address = ip_address
user.last_poll = timezone.now()
user.save()

View File

@@ -25,7 +25,7 @@ SECRET_KEY = "django-insecure-rh0s*u8&#4$uugtt10cxbifjriaz%@&p1w!)c2=y^undd2*nx5
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
ALLOWED_HOSTS = ["10.20.4.109", "73.7.29.136", "localhost", "127.0.0.1", "http://localhost:5173"]
ALLOWED_HOSTS = ["*"]
# ALLOWED_HOSTS = []