Skip to content

dheenaranjith2011-coder/MathServer

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Ex.05 Design a Website for Server Side Processing

Date:1.10.2025

AIM:

To design a website to calculate the power of a lamp filament in an incandescent bulb in the server side.

FORMULA:

BMI = W/H2 BMI --> Body Mass Index W --> Weight H --> Height

DESIGN STEPS:

Step 1:

Clone the repository from GitHub.

Step 2:

Create Django Admin project.

Step 3:

Create a New App under the Django Admin project.

Step 4:

Create python programs for views and urls to perform server side processing.

Step 5:

Create a HTML file to implement form based input and output.

Step 6:

Publish the website in the given URL.

PROGRAM :

math.html
<!DOCTYPE html>
<html>
<head>
    <title>BMI Calculator</title>
    <style>
        body {
            background-color:yellow;
            display: flex;
            justify-content: center;
            align-items: center;
            height: 100vh;
        }
        .box {
            background-color: Grey;
            width: 400px;
            padding: 25px;
            border-radius: 20px;
            text-align: center;
        }
        input {
            margin: 8px;
            padding: 10px;
            width: 50%;
        }
        input[type="submit"] {
            width: auto;
            background-color:  white;
            color: Red;
            cursor: pointer;
        }
        .result {
            margin-top: 10px;
            font-weight: 800;
        }
    </style>
</head>
<body>
    <div class="box">
        <h2>BMI CALCULATOR</h2>
        <h3>Name: DHEENADHAYA S R</h3>
        <h3>Reg No: 25017597</h3>

        <form method="post">
            {% csrf_token %}
            <label>Height (cm):</label><br>
            <input type="number" name="height" required>
            <br>
            <label>Weight (kg):</label>
            <br>
            <input type="number" name="weight" required>
            <br>
            <input type="submit" value="CALCULATE BMI">
        </form>
        
        <div class="result">
            Your BMI: {{ bmi }}
        </div>
    </div>
</body>
</html>

views.py
from django.shortcuts import render

def bmi_calculator(request):
    bmi = None
    category = None
    height = None
    weight = None

    if request.method == "POST":
            height = float(request.POST.get("height"))
            weight = float(request.POST.get("weight"))
            bmi = round(weight / ((height/100) ** 2), 2)
            print(f"height : {height} cm, weight : {weight} kg, bmi : {bmi}")
    return render(request, "mathapp/math.html",{"bmi": bmi})

    urls.py
    from django.contrib import admin
from django.urls import path
from mathapp import views

urlpatterns = [
    path("admin/", admin.site.urls),
    path("bmi/", views.bmi_calculator, name="bmi_calculator"),
]


SERVER SIDE PROCESSING:

alt text

HOMEPAGE:

alt text

RESULT:

The program for performing server side processing is completed successfully.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 79.7%
  • HTML 20.3%