Use of Flask Web Framework - Introduction to Web Framework


I. Introduction

  • Personal homepage : ζ Xiaocaiji
  • Hello everyone, I am Xiaocaiji, let us learn the use of the Flask Web framework-Introduction to the Web Framework
  • If the article is helpful to you, welcome to follow, like, and bookmark (one-click three links)

2. Introduction

   If you've built some websites from scratch, you may have noticed that you have to solve some of the same problems over and over again. Doing this is tiresome and violates one of the core principles of good programming - DRY (Don't Repeat Yourself).

   Experienced web developers run into similar problems when creating new sites. Of course, there are always some special cases that will vary from site to site, but in most data cases, developers usually need to deal with four tasks - data creation, reading, updating and deleting, also known as CRUD. Fortunately, these problems are well solved by web frameworks.


3. What is a Web Framework

   Web frameworks are software frameworks used to simplify web development. Frameworks exist to save you from reinventing the wheel, and to help alleviate some of the overhead when creating a new website. A typical framework provides the following commonly used functions:

  • manage routing
  • access database
  • Manage sessions and cookies
  • Create templates to display HTML
  • Facilitate code reuse

   In fact, frameworks are nothing new at all, they're just Python files that implement common functionality. We can think of a framework as a collection of tools rather than something specific. Frameworks exist to make building websites faster and easier. Frameworks also facilitate code reuse.


4. Common Web Frameworks

  WSGI (Server Gateway Interface), which is a simple and common interface between web servers and web applications. In other words, as long as the WSGI interface rules are followed, the Web framework can be developed independently. Therefore, there are at least hundreds of various open source web frameworks, and the discussion about the pros and cons of Python frameworks continues. As a beginner, you should choose some mainstream frameworks to learn to use. This is because the mainstream framework has complete documentation, more technology accumulation, a thriving community, and better support. The following introduces several mainstream web frameworks of Python.


1.Flask

  Flask is a lightweight web application framework. As its name suggests, it's basically a tiny glue framework that glues Werkzeug and Jinja together so it's easily extensible. Flask also has many extensions that you can use, Flask also has a group of loyal fans and a growing user base, it has a very comprehensive documentation, and even a handy common example. Flask is very easy to use, you only need a few lines of code to write a "hello world".


2.Django

  This is probably the most well known and used Python web framework. Django has the world's largest community, with the most packages. Its documentation is very complete, and it provides a one-stop solution, including caching, ORM, background management, validation, form processing, etc., making it easy to develop complex database-driven websites. However, the Django system is highly coupled, and it is troublesome to replace built-in functions.


3.Bottle

  This framework is relatively new. Bottle is a veritable microframework - it's only about 4500 lines of code. It doesn't have any dependencies other than the Python standard library, and it even has its own unique bit of templating language. Bottle's documentation is detailed and captures the essence of things. Much like Flask, it also uses decorators to define paths.


4.Tornado

  Tornado is not only a framework, but also a web server. It was originally developed for FriendFeed and later made available for Facebook in 2009. It was born to solve real-time services. To do this, Tornado uses asynchronous non-blocking IO technology, so it runs very fast.


  The above four frameworks have their own advantages and disadvantages. When using them, you need to choose a suitable web framework according to your own application scenarios.


  This is the end of the introduction of the use of the Flask web framework-the introduction of the web framework. Thank you for reading. If the article is helpful to you, welcome to pay attention, like, and favorite (one-click three links)


Guess you like

Origin blog.csdn.net/weixin_45191386/article/details/131650750