Creating a Python Web Application using Python Flask
Creating a Python Web Application using Python Flask
There is no better technique than using Python Flask outside of NodeJS in terms of speed, development, and flexibility when developing a web application and performing a large performance.
For the development environment, I recommend using the Ubuntu Virtual Machine hosted inside the Virtual Box. For instructions on how to install and build your own Linux virtual machines.
Visual Studio Code is used here as an IDE, other strong recommendations are the basis for Eclipse Web development with Python Addon or Pycharm Community.
You can also use AWS EC2 as your development environment, which gives you the added benefit of installing gunicorn and nginx to serve and run the page.
Also, in this, we will be setting up an AWS account, creating an IAM user that can talk to a nosql dynamo database, installing the AWS python SDK named BOTO, then importing a bootstrap theme, and using the Python Jinja framework to manage views.
Once you get your development environment set up in such a way you can run Python, whether it be Windows or the VM solution, next we need to install Flask via PIP.
This can be done by running a “pip install flask” in a Terminal. Now create a new folder for your project and open the folder in your IDE. Now we need to set up a project folder to host a simple page in the environment.
Let’s create these sub-folders
app — app module
app/controllers — these will host back end python methods in a modular way.
app/static — This creates a front-end web page.
app/templates — It hosts a file, index.html, Flask uses this directory to render pages, using the built-in template engine.
We can use it to make a server-side template, which is fine, but then we don't get the amazing power of Angular to run on the client-side.
Now let us create these files:
run.py — entry script