Python Web Framework -- Bottle

Source: Internet
Author: User

I saw an article about Bottle and found it interesting. So I searched for some interesting things and summarized them as follows.

On the five main Python Web framework (http://www.cnblogs.com/babykick/archive/2011/11/28/2265920.html) introduced several Python Web framework, and then looked at the Web framework competition evaluation (http://www.cichui.com/the-great-web-framework-shootout/), think Bottle and Flask very interesting, so I want to know about it.

The following sample code shows which one would you like?

Web. py

import web      urls = (    '/(.*)', 'hello')app = web.application(urls, globals())class hello:            def GET(self, name):        if not name:             name = 'World'        return 'Hello, ' + name + '!'if __name__ == "__main__":    app.run()

Flask,

from flask import Flaskapp = Flask(__name__)@app.route("/")def hello():    return "Hello World!"if __name__ == "__main__":    app.run()

Bottle,

from bottle import route, run@route('/:name')def index(name='World'):    return '<b>Hello %s!</b>' % namerun(host='localhost', port=8080)

So I chose Bottle.Django is not taken into account in other languages.

 

  By the way, I also learned what the Web Framework and MVC are.

Web FrameWork and MVC
Currently, Web development supports various technologies, languages, and frameworks. The so-called framework, I understand, is a general architecture, which solves repetitive work or constant work, so that developers can focus on other aspects. Now it seems that when talking about the Web framework, we will talk about MVC.
(MVC details: understand the real so-called "Framework" http://cjwxd126715.iteye.com/blog/349678)
MVC, Model-View-Control, because Web applications become more and more complex, there will be a variety of data, there will be a variety of page display, at the very beginning, using HTML to write page display, involving interactive data, when the page display is changed, Javacript or Java code is embedded in HTML, and various codes are embedded in the background to process data and control page display, which makes the Web program structure messy. Therefore, we hope to make Web development more logical, have a clearer structure, and have MVC. Data is saved using the Model. The View only controls display-related, Control, and specific processing data. In MVC, the original intent of the View should be "the View should only contain the display-related logic, but should not have any other logic, such as accessing the database and calling the business logic ".
In all the MVC frameworks, is the View part "only related to the display logic? Can a View exists independently from the data part? Whether JSP, Velocity, or TagLib is used, View must know the data structure of the objects in use, and access the various attributes of these objects to display them. Are the views and models separated? Can they be separated? (MVC myth http://www.iteye.com/topic/6284)

(IoVC, a new programming thought http://www.iteye.com/topic/176066)
IoVC wants to set an ID for each component in the View through the art design, and then the programmer can have full control over the page elements in the view through the ID in the background logic business. After the Web page is completed by the artist, the programmer no longer needs to re-maintain the Web page content because of changes in requirements or logic. This is also very interesting.

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.