Web frameworks
The MVC pattern
A very simple application
Application of the MVC pattern
Making a Django application
Setting up a Django project
Setting up a Django application
Programming the Django application
Equipping the input page with output results
Handling multiple input variables in Django
Programming the Django application
Custom validation
Customizing widgets
Resources
Exercises
Exercise 1: Add two numbers
Exercise 2: Upload data file and visualize curves
Exercise 3: Plot a user-specified formula
Exercise 4: Visualize Taylor polynomial approximations
Django resources
Computational scientists may want to offer their applications through a web interface, thereby making a web application. Basically, this means that users can set input data to the application on a web page, then click on some Compute button, and back comes a new web page with the results of the computations. The web interface can either be used as a GUI locally on the scientist's computer, or the interface can be depolyed to a server and made available to the whole world.
Web applications of the mentioned type can be created from scratch using CGI scripts in (e.g.) Python, but the code quickly gets longer and more involved as the complexity of the web interface grows. Nowadays, most web applications are created with the aid of web frameworks, which are software packages that simplify the programming tasks of offering services through the Internet. The downside of web frameworks is that there is a significant amount of steps and details to learn before your first simple demo application works. The upside is that advanced applications are within reach, without an overwhelming amount of programming, as soon as you have understood the basic demos.
We shall explore the very popular Django framework in the following. The primary advantage of Django over other web frameworks is the rich set of documentation and examples. Googling for "Django tutorials" gives lots of hits including a list of web tutorials and a list of YouTube videos. There is also an electronic Django book. However, there is hardly any example on using Django for scientific applications. The forthcoming text provides specific examples on how to webify some typical scienticic applications.
The problem for a computational scientist who wants to enable mathematical calculations through the web is that most of the introductory examples on utilizing a particular web framework address web applications of very different nature, e.g., blogs and polls. Therefore, we have made an alternative introduction which explains, in the simplest possible way, how web frameworks can be used to
All the files associated with this document are available in a GitHub repository. The relevant files for the web applications are located in a subtree doc/src/web4sa/src-web4sa/apps of this repository.