The nature of the Web framework: Socket accept request + content processing + socket response.
But Django doesn't have a socket to use other Socket+django
The socket has many of the following
But they must follow a specification WSGI (Web Services Gateway Interface)
Django uses WGIREF sockets by default (low concurrency performance test)
Uwsgi+django in the work
Wsgiref +django Work Flow
1.socket Accept client requests for HTTP request parsing (Split request header request body)
2.wsgiref forward the parsing request related information to Django
3.Django execution processing, return output string, back to Wsgi
4. Send the socket (the Django output character string) back to the client
wsgi+Django fromWsgiref.simple_serverImportMake_serverdefrunserver (environ, start_response): The Django framework begins the middleware routing system view Graph function ..... Start_response ('OK', [('Content-type','text/html')]) return[Bytes ('', encoding='Utf-8'), ] if __name__=='__main__': httpd= Make_server ('127.0.0.1', 8000, Runserver) httpd.serve_forever ()
View Code
Mvc/mtv
Is there someone who often put B in front of you to mention MVC and MTV?
The white is to do function module division, put different code to different files.
Mvc
Models (database, model)
Views (HTML Template)
Controllers (Business logic processing)--MVC
Mtv
Models (database, model)
Templates (HTML template)
Views (business logic Processing)--MTV (Django belongs to MTV)
Django's Wsgi and MVC/MTV