mirror of
https://github.com/AmanTahiliani/PeerNotes.git
synced 2026-08-07 11:55:12 -04:00
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:
@@ -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()
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -25,7 +25,7 @@ SECRET_KEY = "django-insecure-rh0s*u8$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 = []
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user