Flask python

 What is Flask?

Flask is a python-based web framework that offers libraries for creating lightweight web applications. It is created by Armin Ronacher who drives a worldwide gathering of python fans (POCCO).


The jinja2 template engine and WSGI toolkit serve as their foundations. The carafe is viewed as a miniature system.


What is WSGI?


It is a Python web application development standard that stands for "web server gateway interface."It is regarded as the universal interface specification for the web server and web application.

Why is WSGI necessary?


Python applications can't be run on a standard web server because it doesn't understand or support them. Grisha Trubetskoy, a software developer, created the mod_python Apache module in the late 1990s to run any Python code.


Most Python web applications were run by Apache configured with mod_python for several years in the late 1990s and early 2000s.

Mod_python, on the other hand, was not a standard specification.


It was merely an implementation that enabled server-side Python code execution. The community realized that a consistent method for executing Python code for web applications was required as mod_python's development stalled and security flaws were discovered.


WSGI was developed as a standard interface for modules and containers by the Python community. Nowadays, WSGI is the standard method for running Python web applications.


what is jinja2?


Jinja2 is helpful in light of the fact that it has a predictable layout label grammar and the task is neatly separated as a free open-source project so it very well may be utilized as a reliance by other code libraries.


The Jinja2 engine strikes a thoughtful balance on the template engine spectrum, allowing developers to code whatever they want while allowing users to embed arbitrary code in templates.


The Jinja2 engine was certainly not the first template engine. In point of fact, the syntax of Jinja2 is derived from the pre-released built-in template engine of Django.


Before Jinja2, there were numerous template systems, such as JavaServer Pages (JSPs), which were developed almost a decade earlier. The concepts of other template engines were used to build Jinja2, which is now widely used by the Python community.


Installing Flask


Since the Python programming language powers the Flask web framework, we will need to install Python.


However, Python might already be installed on your system; Open your terminal (or cmd in Windows) and type the command to see if Python is installed.


When you run either of the commands, the version should appear in your terminal if you already have Python installed. We will now go over the process of installing Python if you do not already have it installed.


Creating a Base Application

Flask will be used for the first time once your programming environment is set up. In this step, you'll make a little web application inside a Python record and run it to begin the server, which will show some data on the program.


Open the hello.py file in your flask_blog directory for editing with nano or your preferred text editor.

Using HTML templates

Your application currently only displays a straightforward message without HTML.


You will now work on incorporating HTML files into your app so that they can be displayed in the web browser because web applications primarily use HTML to display information for users.


Flask has a helper function called render_template() that lets you use the Jinja template engine. Using logic in your HTML code and writing it in.html files, will make managing HTML much simpler.


These HTML files—also known as templates—will be used to construct all of the pages of your application, including the main page that displays the most recent blog posts, the page for each blog post, the page where users can add new posts, and so on.


You will create your main Flask application in a new file during this step.

To start with, in your flask_blog registry, use nano or your number one manager to make and alter your app.py record.


All of the code you'll need to build the blogging application will be stored here.


I hope that my article was beneficial to you. To learn more, click the link here


Comments

Popular posts from this blog

Web activities in azure data factory

DevOps engineer skill

DevOps deployment tools