To design a website to perform mathematical calculations in server side.
first fork the given repository link and then copy your code.
open visual stuido and create a folder and then clone the copied link using 'git clone [your link ]' and then activate Django
open the folder and then inside the repository folder create myproj folder using 'django-admin startproject myproj' command. And then open myproj folder inside the myproj folder we can create a app folder called 'myapp' using 'python manage.py startapp [your app name]' command
open 'settings.py' inside the myproj folder and make some changes. And then create a folder called 'templates' and then inside the templates create another folder (your app folder) named 'myapp'
inside the myapp folder create 2 html files named 'math.html' , 'result.html' and then paste the codes that are given below. And then make the changes in 'url.py' and 'views.py'.Save all files and then run the code using 'python manage.py runserver [port number]
Publish the website in the given URL.
#views.py from django.shortcuts import render from django.template import loader from django.shortcuts import render def prismarea(request): context={} context['area'] = "0" context['s'] = "0" context['b'] = "0" if request.method == 'POST': print("POST method is used") s = request.POST.get('side','0') h = request.POST.get('height','0') print('request=',request) print('side=',s) print('height=',h) area = 2int(s) **2+4int(s)*int(h) context['area'] = area context['s'] = s context['h'] = h print('Area=',area) return render(request,'myapp/math.html',context) #math.html
<title>Area of Prism</title> <style type="text/css"> body { background-color:cyan; } .edge { width: 1080px; margin-left: auto; margin-right: auto; padding-top: 200px; padding-left: 300px; } .box { display:block; border: Thick dashed lime; width: 500px; min-height: 300px; font-size: 20px; background-color: purple; } .formelt{color: Red; text-align: center; margin-top: 5px; margin-bottom: 5px; } h1 { color: yellow; text-align: center; padding-top: 20px; } </style> #result.html <title>SEC demo on server processing result</title> The result is {{result}}when the serverside output was created susessfully
