routie dev init since i didn't adhere to any proper guidance up until now
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,3 @@
|
||||
from django.contrib import admin
|
||||
|
||||
# Register your models here.
|
||||
@@ -0,0 +1,5 @@
|
||||
from django.apps import AppConfig
|
||||
|
||||
|
||||
class ApiConfig(AppConfig):
|
||||
name = 'api'
|
||||
Binary file not shown.
@@ -0,0 +1,3 @@
|
||||
from django.db import models
|
||||
|
||||
# Create your models here.
|
||||
@@ -0,0 +1,3 @@
|
||||
from django.test import TestCase
|
||||
|
||||
# Create your tests here.
|
||||
@@ -0,0 +1,33 @@
|
||||
from django.shortcuts import render
|
||||
from rest_framework.decorators import api_view
|
||||
from rest_framework.response import Response
|
||||
from django.utils import timezone
|
||||
from django.http import JsonResponse
|
||||
from datetime import timedelta
|
||||
|
||||
@api_view(['GET'])
|
||||
def hello(request):
|
||||
return Response({"message": "Hello from Django!"})
|
||||
|
||||
def accept_disclaimer(request):
|
||||
request.session['disclaimer_accepted_at'] = timezone.now().isoformat()
|
||||
return JsonResponse({'ok': True})
|
||||
|
||||
def check_disclaimer(request):
|
||||
accepted_at = request.session.get('disclaimer_accepted_at')
|
||||
|
||||
if not accepted_at:
|
||||
return JsonResponse({'accepted': False})
|
||||
|
||||
accepted_time = timezone.datetime.fromisoformat(accepted_at)
|
||||
if timezone.now() - accepted_time > timedelta(minutes=30):
|
||||
return JsonResponse({'accepted': False})
|
||||
|
||||
return JsonResponse({'accepted': True})
|
||||
|
||||
from django.views.decorators.csrf import csrf_exempt
|
||||
|
||||
@csrf_exempt
|
||||
def accept_disclaimer(request):
|
||||
request.session['disclaimer_accepted_at'] = timezone.now().isoformat()
|
||||
return JsonResponse({'ok': True})
|
||||
Reference in New Issue
Block a user