Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

A brief introduction to the Python Development Framework

2025-03-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article introduces the relevant knowledge of "A brief introduction to the Python Development Framework". Many people will encounter such a dilemma in the operation of actual cases, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

1. Flask

Open source Web framework based on BSD protocol, it is a lightweight Web framework that starts very quickly and easily. It relies on Werkzeug, the WSGI, the WSGI tool (for receiving routing requests) and the Jinja2 template (for rendering web pages). It uses a simple core plus extension architecture, that is, in addition to the core functions, other functions need you to choose the corresponding library to provide functionality. Of course, the authorities have provided you with some commonly used libraries. The simplicity of Flask can be seen in the code. For example, the following code outputs the information of Hello and world pages:

From flask import Flaskapp = Flask (_ _ name__) @ app.route ("/") def hello (): return "Hello World!" if _ _ name__ = = "_ main__": app.run ()

Flask's official website address is: https://palletsprojects.com/p/flask/, interested students can go to the official website to study its official documents.

2. Django

As we mentioned above, Flask's philosophy is simple, then Django's philosophy should be big and comprehensive. The internal module of Django provides almost most of the functions needed for Web development, such as user authentication, database migration, Session, Cookie management, and so on. Its template engine, like Flask, is based on Jinja2. At the same time, its object-relational mapping (ORM) function is very simple to manipulate data directly through the model. Developers only see the class model in Python, while at the bottom, no matter whether you use MySQL or databases such as PostgreSQL or Oracle, you can use the model directly, which greatly reduces the difficulty of dealing with the database. It saves a lot of time for developers. It even provides you with a direct management background, so that you can directly manage the corresponding data information, which can be said to be a universal toolbox, so Django has been adopted by major websites.

If you want to try to develop a Django website, you can try it according to the following code:

# 1. Open the windows command line window or linux's shell window, and install the django module pip install django# 2. 0. Creating a django project generates a demo project folder django-admin startproject demo# 3. 0 in the current directory. Change to the demo folder, where there is a file manage.py and demotion subdirectory (configuration file directory) # cd demo; ls demodemo manage.py# 4. 0. Open the settings.py file in the demotion subdirectory, find the ALLOWED_HOSTS configuration, and change it to the following value ALLOWED_HOSTS = ['127.0.0.1 commands,] # 5. To start the demo project, the command is: python manage.py runserver 0.0.0. 0. 0. 0. 0. 0. Open the browser and enter the address http://127.0.0.1:8000

At this point you will see the following demo page:

Students who want to try can take a look at django's official website. Django is also one of the few development frameworks that provide Chinese documents. Its official website address is http://djangoproject.com.

3. Web2py

Web2py framework is an open source full-stack framework, which can be used to develop fast, scalable, secure and removable database-driven web applications. It is characterized by:

Bring your own battery. Everything you need is included in the official bag.

Easy to run, do not need installation and configuration, but all through the web interface to manage and configure.

Support a variety of web servers, and can cooperate well with mainstream browsers such as Nginx and Apache through WSGI protocol

Supports a variety of back-end databases, such as SQLite, PostgreSQL, MySQL, MSSQL, etc.

Web2py's official website page is www.web2py.com, which provides an online page to try to develop web2py applications at https://www.pythonanywhere.com/try-web2py/.

Dash

Dash is also an open source framework, it is mainly used for the development of data analysis web pages, for data scientists, data analysts developed a Web framework. It is built on Flask,Plotly.js and React.js. Through a few simple patterns, Dash abstracts all the technologies and protocols needed to build Web-based interactive applications.

Dash applications are rendered in Web browsers and can be deployed to a server and then shared through URL.

Because Dash applications are viewed in Web browsers, Dash is essentially cross-platform and mobile.

Dash's official website page is: https://plot.ly/dash/

5. Bottle

Compared with the above frameworks, bottle can be said to be a miniature web framework, it provides all the functions through a simple resource file, so this web framework is generally used to design web api, its standard library does not have any dependencies, that is, you can use it in combination with other frameworks. The use of bottle is also very simple. The sample code is as follows:

From bottle import route, run, template@route ('/ hello/') def index (name): return template ('Hello {{name}}!', name=name) run (host='localhost', port=8080)

Execute the code file, and then open the address in the browser

Http://127.0.0.1:8080/hello/world/

You can see the word Hello world displayed on the web page. Bottle's official website is: http://www.bottlepy.org/, interested students can go up and have a look.

This is the end of "A brief introduction to Python Development Framework". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report