1 let querystring = require('querystring')
2 let stream_buffers = require('stream-buffers')
5 if (env.request.method == 'POST') {
6 let write_stream = new stream_buffers.WritableStreamBuffer()
7 let data = new Promise(
10 on('finish', () => {resolve(write_stream.getContents())}).
11 on('error', () => {reject()})
14 env.request.pipe(write_stream)
15 let query = querystring.parse((await data).toString())
16 let a_length = parseFloat(query.a_length)
17 let b_length = parseFloat(query.b_length)
18 let height = parseFloat(query.height)
19 let area = (a_length + b_length) / 2 * height
26 <link rel="stylesheet" type="text/css" href="olly.css">
27 <title>Calculation</title>
30 <h1>The Height is: ${height} units</h1>
31 <h1>The A length is: ${a_length} units</h1>
32 <h1>The B length is: ${b_length} units</h1>
33 <h1>The area is: ${area} units<sup>2</sup></h1>
41 Buffer.from(_out.join('')),
42 'calculate_button_trapezium.html.jst'
51 <link rel="stylesheet" type="text/css" href="olly.css">
52 <title>Calculation</title>
55 <h1>Error - Unable to Calculate</h1>
63 Buffer.from(_out.join('')),
64 'calculatebutton.html.jst'