Add hexa id generator

This commit is contained in:
ismailsosic
2022-05-09 09:51:31 +02:00
parent 5e3964381c
commit 8c59061da5
11 changed files with 46 additions and 3 deletions

View File

View File

@@ -0,0 +1,3 @@
from django.contrib import admin
# Register your models here.

View File

@@ -0,0 +1,6 @@
from django.apps import AppConfig
class GeneratorConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'Generator'

View File

@@ -0,0 +1,3 @@
from django.db import models
# Create your models here.

View File

@@ -0,0 +1,3 @@
from django.test import TestCase
# Create your tests here.

View File

@@ -0,0 +1,6 @@
from django.urls import path
from Generator import views
urlpatterns = [
path('', views.HexaGenerator)
]

View File

@@ -0,0 +1,12 @@
from rest_framework.decorators import api_view
from rest_framework.response import Response
import secrets
# Create your views here.
@api_view(['GET'])
def HexaGenerator(request):
if request.method == 'GET':
hexa_id = secrets.token_hex(16)
return Response({"message": "Search id:", "data": hexa_id})