Make a web application that reads two numbers from a web page,
adds the numbers, and prints the sum in a new web page.
Package the necessary files that constitute the application
in a tar file.
Filename: add2.tar.gz
.
vib3_flask
app
Add a new argument x_axis
to the compute
function in the
vib_flask3 application from the section Autogenerating the code. The x_axis
argument measures the extent
of the \( x \) axis in the plots in terms of the number of standard
deviations (default may be 7). Observe how the web interface
automatically adds the new argument and how the plots adapt!
vib3_flask
app with more data types
In the vib_flask3
application from the section Autogenerating the code,
use the label
argument in the form field objects to add an
information of the type of data that is to be supplied in the
text field. Extend the model.py
file to also handle
lists, tuples, and Numerical Python arrays. For these three
new data types, use a TextField
object and run eval
on the text in the view.py
file.
A simple test is to extend the compute
function with an
argument x_range
for the range of the \( x \) axis, specified as
an interval (2-list or 2-tuple).
Filename: vib3_ext.tar.gz
.
Given a compute
with a set of positional and keyword
arguments, the purpose of this exercise is to automatically generate the
Flask files model.py
and view.py
. Use the Python inspect
module, see the section Autogenerating the code, to extract
the positional and keyword arguments in compute
, and use this
information to construct the relevant Python code. Assume as
in the section Autogenerating the code that the user provides
a file view_results.html
for defining how the returned object
from the compute
function is to be rendered.
Test the code generator on the compute
function in the vib1_flask
application to check that the generated
model.py
and view.py
files are correct.
Filename: generate_flask.py
.