How do you write this code using the flask packages in python. Mini-Project Cons
ID: 3600382 • Letter: H
Question
How do you write this code using the flask packages in python. Mini-Project Consider the following command-line program example run: This program computes the volume and surface area of cubes and spheres. What is your name? DO What is the side length of your cube? 1 What is the radius of your sphere? 1.5 Report for DC: Cube volume: 1.0 Cube surface area: 6.0 Sphere volume: 14.137166941154067 Sphere surface area: 28.274333882308138 Your task for this lab is to write a single-page Web application using Flask that has the same functionality. The application should read input from a Web form and render the output in the browser.Explanation / Answer
<%@page import="sun.launcher.resources.launcher"%>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<form action="Test.jsp" method="get">
<table>
<tr><!--Here We take Input On WebPage From User Name -->
<td>Enter Your Name</td>
<td><input type="text" name="name"></td>
</tr>
<tr><!--Here We take Input On WebPage From User side Length of Cube -->
<td>Enter The Side Length Of Your Cube</td>
<td><input type="text" name="length"></td>
</tr>
<tr><!--Here We take Input On WebPage From User Radius of sphere -->
<td>Enter The Radius Of Your Sphere</td>
<td><input type="text" name="radius"></td>
</tr>
<tr>
<td><input type="submit" value="Get Result" ></td>
</tr>
</table>
</form>
<%
//comments here we take data from form that are we submittend in above text field
String name = request.getParameter("name");
if (name != null) {
String lengthStr = request.getParameter("length");
int length = Integer.parseInt(lengthStr);
// belove we calculated volume of cube using lcube formula
double volumeOfCube = length * length * length;
//we calculated suface area of cube using 6*l squere formula
double surfaceAreaOfCube = 6 * (length * length);
double radius = Double.parseDouble(request.getParameter("radius"));
//we calculated volume of sphere ussing 4*pi*r3 formula
double volumeOfSphere = 4/3*3.14159*(radius*radius*radius);
//we calculated suface area of sphere using 4*pi*r2 formula
double surfaceAreaOfSphere = 4 *3.14159*(radius*radius);
%>
<!-- Here We Shows all Result -->
Cube Volume: <%=volumeOfCube%><br>
Cube Surface Area: <%=surfaceAreaOfCube%><br>
<br><br>
Sphere Volume: <%=volumeOfSphere%><br>
Sphere Surface Area: <%=surfaceAreaOfSphere%><br>
<%
}
%>
</body>
</html>
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.