To design a website to find total surface area of a square prism in server side.
Total Surface Area = 2b2 + 4bh
b --> Base of Square Prism
h --> Height of Square Prism
Clone the repository from GitHub.
Create Django Admin project.
Create a New App under the Django Admin project.
Create python programs for views and urls to perform server side processing.
Create a HTML file to implement form based input and output.
Publish the website in the given URL.
<html>
<head>
<meta charset='utf-8'>
<meta http-equiv='X-UA-Compatible' content='IE=edge'>
<title>Area of Square Prism</title>
<meta name='viewport' content='width=device-width, initial-scale=1'>
<style type="text/css">
body {
background-color:white;
}
.edge {
display: flex;
height: 100vh;
width: 100%;
justify-content: center;
align-items: center;
}
.box {
display: block;
width: 500px;
min-height: 300px;
font-size: 20px;
background: rgb(142, 152, 7);
background: linear-gradient(90deg, rgb(152, 7, 104) 9%, rgb(150, 7, 90) 56%);
border-radius: 10px;
box-shadow: rgba(0, 0, 0, 0.35) 0px 5px 15px;
}
.formelt {
color: whitesmoke;
text-align: center;
margin-top: 7px;
margin-bottom: 6px;
}
h1 {
color: white;
text-align: center;
padding-top: 20px;
}
input{
margin: 5px;
padding: 5px;
border-radius: 5px;
border: none;
}
</style>
</head>
<body>
<div class="edge">
<div class="box">
<h1>Area of Square Prism</h1>
<form method="POST">
{% csrf_token %}
<div class="formelt">
Side : <input type="text" name="length" value="{{a}}"></input>(in m)<br />
</div>
<div class="formelt">
Height : <input type="text" name="breadth" value="{{h}}"></input>(in m)<br />
</div>
<div class="formelt">
<input type="submit" value="Calculate"></input><br />
</div>
<div class="formelt">
Area : <input type="text" name="area" value="{{area}}"></input>m<sup>2</sup><br />
</div>
</form>
</div>
</div>
</body>
</html>
from django.shortcuts import render def prismarea(request): context={} context['area'] = "0" context['a'] = "0" context['h'] = "0" if request.method == 'POST': print("POST method is used") a = request.POST.get('length','0') h = request.POST.get('breadth','0') print('request=',request) print('Length=',a) print('Breadth=',h) area = 2*(int(a)**2) + 4*int(a)*int(h) context['area'] = area context['a'] = a context['h'] = h print('Area=',area) return render(request,'mathapp/math.html',context) ``` from django.contrib import admin from django.urls import path from mathapp import views urlpatterns = [ path('admin/', admin.site.urls), path('areaofprism/',views.prismarea,name="areaofprism"), path('',views.prismarea,name="areaofprismroot") ]
## OUTPUT:
![value 2](https://github.com/mustbenandan/MathServer/assets/129033280/a4d80c15-4cb6-4bdc-9d0f-ce6297b84739)
![33](https://github.com/mustbenandan/MathServer/assets/129033280/79f94375-ce21-4cc2-9523-d82cf2cb7563)
## RESULT:
The program for performing server side processing is completed successfully.