2024-02-23 14:26:25 +01:00

32 lines
952 B
Python

from django.shortcuts import render
from django.http import HttpResponse, JsonResponse
from migration.models import ShoppingItem
def index(response):
return HttpResponse("Welcome to siMed Migration")
def migration_home(request):
if request.method == 'POST':
print('Received Data',request.POST['itemName'])
ShoppingItem.objects.create(name= request.POST['itemName'])
all_items = ShoppingItem.objects.all()
return render(request,'migration.html',{'all_items': all_items})
def api_home(request,endpoint, params={"message": "Your JSON Repsonse"}):
body = request.body
data = {}
try:
data = json.loads(body)
except:
pass
print(request.GET)
print(data)
data['params'] = dict(request.GET)
data['headers'] = dict(request.headers)
data['content_type'] = request.content_type
return JsonResponse(data)
##return JsonResponse()