let query = querystring.parse((await data).toString())
let radius_and_units = query.radius.split(' ')
-
-let radius = parseFloat(radius_and_units[0])
-let units = radius_and_units[1] || 'units'
-let area = Math.PI * radius * radius
-let circumference = Math.PI * radius * 2
-let diameter = radius * 2
-
- _site.serve(
- env,
- 200,
+ let radius = parseFloat(radius_and_units[0])
+ let units = radius_and_units[1] || 'units'
+ let area = Math.PI * radius * radius
+ let circumference = Math.PI * radius * 2
+ let diameter = radius * 2
+ if (radius < 0) {
+ _site.serve(
+ env,
+ 200,
+ `<!DOCTYPE html>
+<html>
+<head>
+<title>Hello World HTML</title>
+</head>
+<body>
+<h1>Error - Unable to Calculate Negative Radius</h1>
+</body>
+</html>
+`,
+ 'calculatebutton.html.jst'
+ )
+ }
+ else {
+ _site.serve(
+ env,
+ 200,
`<!DOCTYPE html>
<html>
<head>
</body>
</html>
`,
- 'calculatebutton.html.jst'
- )
+ 'calculatebutton.html.jst'
+ )
+ }
}
else {
_site.serve(
<title>Hello World HTML</title>
</head>
<body>
-<h1>404 Error - Unable to Calculate</h1>
+<h1>Error - Unable to Calculate</h1>
</body>
</html>
`,