Flask/Tornado/Django

Python-depth study, to do the back-end Web Development with Django
now uses Python more widely, server, Web, games, crawlers, data analysis, and artificial intelligence to learn the road is still a long

road of no return technology fall into the trap opinions can not get out just love in general,
learning, project notes impression, the proper way cloud notes, Onenote have in mind a lot
have friends that have been placed there to remember the notes will be moldy, forget;
writing a blog, and occasionally look at their own record own growth, but also considered a Share

Python belongs to the object-oriented interpreted advanced dynamic computer programming language

Learn a language at the head understand its overall structure, basic grammar, built-in data structures, built-in functions, standard library and run mode, the programming mode.

1, Python overall architecture

Python's overall architecture can be divided into three main parts:

The left is built-in module provides Python libraries and user custom module

Python is the right operating environment, including the object / system type, memory allocator, the operation status information

The middle is the core Python interpreter. Python runtime data stream lexical analysis, parsing, compilation, execution

Common standard library

Python <wbr> web development framework rear <wbr> Django <wbr>, Flask, Tornado
The following are visiting the CSDN are fed chicken soup every day, you can sum up the lack of support when Bubu:
    
    programming years in addition to algorithms and data structures, nothing belongs to us.
    Programming is the algorithms and data structures, algorithms and data structures are programmed soul.
    Programming is the most useless thing is the source code, the most useful thing is the algorithms and data structures.
    Algorithms and data structures is the first secret program, lack of algorithms and data structures are the biggest reason for programming.
    Algorithms and data structures is an important part of the program, if you lose the algorithms and data structures, you'll have lost everything.


    Although less write so much code, but it saved time and where is it?
    The code a programmer friend, though without enthusiasm, but very loyal.
    When you can not write their satisfaction with the program, you do not go to sleep.
    Some code should not be forgotten, nor the source code should not be remembered.
    Does not meet the code, it is a fundamental feature of any truly talented programmers.
    There are people who build process code, more valuable than those who are ignorant of the software used.
    Programming is a virtue, is to promote the continuous development of a person upward a driving force.
    Programmer's life time is used on 90% of the programming, while the remaining 10% live in the world.
    The reason why programmers make mistakes, not because they do not understand, but because they knows all the answers.
    Programming and debugging of error is the best thing for you, because every wrong step at the top marked the advance.
    If the program is easy to understand, then the programmer will not be enthusiastic to write notes, will not be happy to get programming.
    Code is the most patient, the most patient and most enjoyable partner at any time of hardship, it will not abandon you

 

由于Python的简洁 易读 强大 高效  现在Python应用在文件处理、网络编程、数据库编程、游戏、Web开发、数据分析、机器学习等各个领域。

就Web开发而言,为了提高开发效率,应运而生了很多框架,如Django、Flask、Tornado、Web2py等。

框架很多,根据业务需求、选择适合的框架。

1、Django

最早接触Django,在我心中的形象是:Web框架界的变形金刚

Django的MVT架构、自带ORM、强大的Admin后台管理、自带数据库、还自带开发测试用的服务器、不得不说服务周到。

如此大而全,重量级的Django给开发者提供了超高的开发效率。

淌着Python血液

MVT三大轮子 连接浏览器 数据库开跑

一身装备 可变形 可扩展

多领域 跨平台 协调作战

自我测试 自我管理 自我保护

友好 开放 国际化

装备很多:

用户认证 缓存 日志 邮件 组织 分页 消息 序列化 会话 网站地图 静态文件处理 数据验证

 

Django支持第三方扩展:

比如:富文本编辑器  缓存 全文检索  celery等

 

Django项目布署 用nginx做静态资源代理、负载均衡 可以提高高并发能力。

 

一些Web项目开发 无论用户量、服务群体、上来总谈高并发。没用户 天天愁高并发问题 还没解决也许项目已经黄了。

项目有了、业务有了、用户有了、性能优化、高并发顺势解决嘛。

当然一些大型网站,在高性能的要求下,框架的各个部分往往都需要自己定制,这样用Django也就没有太大优势。

2、Falsk

相较于Django ,Falsk属于轻量级Web框架,也称‘microframework’。

Flask一个简单的核心,基于Werkzeug WSGI工具箱和Jinja2 模板引擎。其他功能开发者根据业务需求 与喜好 添加。

 

如此 Falsk 自由、灵活、可扩展性很强。很适用于开发小型应用、开发大型网站也没有压力,自己设计架构、选择合适第三方扩展,各方面性能完全不输Django。

常用拓展包:wtf、sqlalchemy、login、script、migrate、mail

 

3、Tornado

传说中实现高并发、高性能的框架。Tornado的全称是Torado Web Server,可用作Web服务器,同时也是一个Python Web的开发框架。

 

Tornado两大核心模块:

iostream :对非阻塞式的 socket 的简单封装,用来处理 socket 的异步读写

ioloop :核心的 I/O 循环。基于 epoll,可以高效的响应网络事

 

其作为Web框架的主要模块

web:包含了 Tornado 的大多数重要的功能
escape :XHTML, JSON, URL 的编码/解码方法
template :基于 Python 的 web 模板系统

httpserver : 非阻塞 HTTP server
httpclient : 异步 HTTP client 用来和web 及 httpserver 协同工作
auth :第三方认证的实现
locale:针对本地化和翻译的支持
等等

Tornado 走的少而精的路子,除了Web开发需要的基本模块,剩下的则都需要开发者自己扩展。比如需要ORM支持,那自己来扩展

 

Python web框架很多,在于精通。选择适合自己的,开始搞起来。

我做项目用的多的还是Django,不自己重复造车轮子嘛。

 

题外话:

目前有一些公司选择Go语言 做所谓的高性能的开发

Go语言 号称可解决现今多核心处理器这一大挑战。
Go语言 专门针对多处理器系统应用程序的编程进行了优化,使用Go编译的程序可以媲美C或C++代码的速度,而且更加安全、支持并行进程。

 

语言皆是工具

框架提高效率的工具

套用CSDN每天的鸡汤:

编程之久除了算法和数据结构,什么也不属于我们。

Programming is the algorithms and data structures, algorithms and data structures are programmed soul.
Algorithms and data structures is an important part of the program, if you lose the algorithms and data structures, you'll have lost everything.

Really I do not know what the developer is left when the machine can optimize their data structures and algorithms, maybe we really only the soul.

Guess you like

Origin www.cnblogs.com/cx2016/p/12057745.html