How does Python write the background of a Web site without frames?

Source: Internet
Author: User
How Python writes the background of a Web site without a frame

Reply content:

Python standard library of Basehttpserver suitable for you, read the source code you know the Django translation document has a phrase:

If you've ever written a Web application. Then you are likely to be familiar with our CGI example before.
Write a Web application from scratch.
Write another Web application from scratch.
Summarize from the first step (find the common code) and apply it in the second step.
Refactoring the code makes it possible to use the generic code in the 1th program in the 2nd program.
Repeat 2-4 steps several times.
Realize that you have invented a framework.
This is why Django was built!

You don't have to implement the framework at the end of the frame, do you? Why not make the wheel again, of course, if it is to upgrade the wagon to a car, it is not to build wheels.
can go to see Liu Xuefeng's tutorial, he is the implementation of the framework, as well as the routine is very detailed recommended Python tutorial-Liaoche's official website Don't say you do not use the framework of the case read this can write, even do not know that Python can write after reading. Look at this. A do-it-yourself Framework You can try using WSGI, a Java-like servlet, and just define a set of interface specifications for the framework to interact with the server, refer to PEP 333-Python Web server Gateway Interface v1.0

The simplest application to write is this:
defsimple_app(environ,start_response):    status='200 OK'    response_headers=[('Content-type','text/plain')]    start_response(status,response_headers)    return['Hello world!\n']
Python comes with a CGI library called CGI

Write a Web site similar to the Perl written decades ago. You need to handle session, cookie, and URL routing yourself.

Performance is also not possible: each HTTP request corresponds to a Python script execution.

Learn a bit, and don't be self-inflicted. PHP can do this because PHP itself has a web framework that comes with the language in addition to the language (see which language has session_start similar functions?). Flask, bottle, Tornado this micro-frame also not?
What about the Werkzeug?
such as uwsgi+werkzeug+ himself to achieve WSGI application
Flask is not the packaging Werkzeug WSGI application?
Add an on-demand database module, session module, etc.

Werkzeug also too big words, that need to realize the thing is a bit more, HTTP parsing, url parsing, url route, and so on, it is a bit out of the CGI? Realize Wsgi, but ... You really don't need a frame? How can you not use frames, sooner or later you'll write a frame yourself
  • 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.