To design a website to calculate the power of a lamp filament in an incandescent bulb in the server side.
P = I2R
P --> Power (in watts)
I --> Intensity
R --> Resistance
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.
math.html
<html>
<head>
<meta charset='utf-8'>
<meta http-equiv='X-UA-Compatible' content='IE=edge'>
<title>POWER OF LAMP IN INCANDESCENT BULD</title>
<meta name='viewport' content='width=device-width, initial-scale=1'>
<style type="text/css">
.box {
display: block;
width: 500px;
min-height: 300px;
font-size: 20px;
background: rgb(21, 208, 215);
background: linear-gradient(90deg, rgb(99, 237, 118) 9%, rgb(193, 166, 202) 56%);
border-radius: 10px;
box-shadow: rgba(239, 5, 24, 0.35) 0px 5px 15px;
}
</style>
</head>
<body>
<div>
<div class="box">
<h1>POWER OF LAMP IN INCANDESCENT BULB</h1>
<form method="POST">
{% csrf_token %}
<div>
INTENSITY : <input type="text" name="Intensity" value="{{I}}"></input>(in A)<br />
</div>
<div >
RESISITANCE : <input type="text" name="Resistence" value="{{R}}"></input>(in Ω)<br />
</div>
<div >
<input type="submit" value="Calculate"></input><br />
</div>
<div>
POWER : <input type="text" name="Power" value="{{Power}}"></input>W<br />
</div>
</form>
</div>
</div>
</body>
</html>
views.py
from django.shortcuts import render
def powerlamp(request):
context={}
context['Power'] = ""
context['I'] = ""
context['R'] = ""
if request.method == 'POST':
print("POST method is used")
I = request.POST.get('Intensity','')
R = request.POST.get('Resistence','')
print('request=',request)
print('Intensity=',I)
print('Resistence=',R)
Power = int(I) * int(I) * int(R)
context['Power'] = Power
context['I'] = I
context['R'] = R
print('Power=',Power)
return render(request,'mathapp/power.html',context)
urls.py
from django.contrib import admin
from django.urls import path
from mathapp import views
urlpatterns = [
path('admin/', admin.site.urls),
path('',views.powerlamp,name="powerlamp"),]
The program for performing server side processing is completed successfully.

