To design a website to perform mathematical calculations in server side.
Requirement collection.
Creating the layout using HTML and CSS.
Write the calculations part in views.py .
Set the path in urls.py .
Run the Server.
Publish the website in the given URL.
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8'>
<meta http-equiv='X-UA-Compatible' content='IE=edge'>
<title>SERVER SIDE PROCESSING</title>
<meta name='viewport' content='width=device-width, initial-scale=1'>
<link rel='stylesheet' type='text/css' media='screen' href='main.css'>
<style>
.container {
width: 1080px;
margin-left: auto;
margin-right: auto;
}
.content {
display: block;
width: 100%;
background-color: white;
min-height: 400px;
margin-top:150px
}
body {
background-color: mediumvioletred;
}
h1{
text-align: center;
padding-top: 20px ;
}
.formelement{
text-align: center;
margin-top: 20px;
margin-bottom: 20px;
font-size: 20px;
}
</style>
</head>
<body>
<div class="container">
<div class="content">
<h1>Area of a Rectangle</h1>
<form method="POST">
{% csrf_token %}
<div class="formelement">
Length = <input type="text" name="length" value={{l}}></input><br/></div>
<div class="formelement">
Breadth = <input type ="text" name="breadth" value={{b}}></input><br/></div>
<div class="formelement">
<input type="submit" value="calculatearea"> </input><br/></div>
<div class="formelement">
Area of Rectangle = <input type ="text" name="area" value={{area}}></input></div>
</form>
</div>
</div>
</body>
</html>
from django.shortcuts import render
# Create your views here.
def areacalculation(request):
context={}
context["area"]="0"
context["l"]="0"
context["b"]="0"
if request.method == "POST":
l= request.POST.get("length","0")
b= request.POST.get("breadth","0")
area= int(l)*int(b)
context["area"]= area
context["l"]=l
context["b"]=b
return render(request,"mathapp/area.html",context)
from django.contrib import admin
from django.urls import path
from mathapp import views
urlpatterns = [
path('admin/', admin.site.urls),
path('areaofrectangle/',views.areacalculation,name="areaofrectangle"),
path('',views.areacalculation,name="areaofrectangleroot"),
]
A website to perform mathematical calculations in server side is designed.