Skip to content

janesha008/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: 04.10.2025

AIM:

To design a website to calculate the Body Mass Index (BMI) 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 :

bmi.html

<html>
    <head>
        <title>
            BMI Calculation
        </title>
        <style>
            body{
                background-color:rgb(197, 240, 255);
            }
            .box{
                margin-left:523px; 
                border: 8px dashed rgb(13, 67, 87); 
                width:350px; 
                height:220px; 
                text-align:center; 
                padding:50px;
            }
        </style>
    </head>
    <body>
        <h1 align="center">Body Mass Index</h1>
        <h2 align="center">Janesha S (25018817)</h2>
        <br><br><br><br>
        <div class="box">
            <h2>BMI Calculation</h2>
            <form method="post" align="center">
                {% csrf_token %}
                <label for="height">Height(in m):</label>
                <input type="text" name="height" value="{{ height }}">
                <br><br>
                <label for="weight">Weight(in kg):</label>
                <input type="text" name="weight" value="{{ weight }}">
                <br><br>
                <input type="submit" value="Calculate BMI">
                <br><br>
                <label for="bmi">BMI(in kg/m^2):</label>
                <input type="text" name="bmi" value="{{ bmi }}" readonly>    
            </form>
        </div>
    </body>
</html>

views.py

from django.shortcuts import render 
def calculate_bmi(request): 
    bmi=None
    height=''
    weight=''
    if request.method == "POST": 
        height = float(request.POST.get("height")) 
        weight = float(request.POST.get("weight")) 
        bmi=(weight/height**2)
        print(f'''Height:{height},
Weight:{weight},
BMI:{bmi:.2f}''') 
    return render(request, 'mathapp/bmi.html', {
        'bmi': bmi,
        'height': height,
        'weight': weight
    })

urls.py

from django.contrib import admin 
from django.urls import path 
from mathapp import views 
urlpatterns = [ 
    path('admin/', admin.site.urls), 
    path('', views.calculate_bmi, name='BMI'), 
] 

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

Packages

Contributors

Languages