Why does Django need a request when it outputs Hello world?

Source: Internet
Author: User
Why do we use the lamp environment, access to the PHP page need to return to Hello world, directly in the file to write Echo ' Hello World ', and Django needs

from django.http import HttpResponsedef index(request):    return HttpResponse('Hello World')~                                         

How about this?

Reply content:

Why do we use the lamp environment, access to the PHP page need to return to Hello world, directly in the file to write Echo ' Hello World ', and Django needs

from django.http import HttpResponsedef index(request):    return HttpResponse('Hello World')~                                         

How about this?

Just encapsulation of the HTTP protocol.
PHP also has a similar library, just because PHP is not a strict object-oriented language, of course, it also supports object-oriented programming.
The advantage of this writing is that it has all the benefits of object-oriented. More readable.

Response('hello!world')->withHeader(['Content-type:text/html;charset=utf8;']);//PHP也可以以这样的方式编程.//当然你也可以这样header('Content-type:text/html;charset=utf8;');echo 'hello!world';

So it's just a way of programming, without having to tangle.

  • 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.