Understanding of the HTTP protocol

1. Recap
1.HTTP protocol message format:
  1. Request (request)
  request Approaches for the HTTP / 1.1 \ R & lt \ n-
  K1: V1 \ R & lt \ n-
  ... \ R & lt \ n-
  \ R & lt \ n-
  request body "- - there can be no
2. response (response)
  the HTTP / 1.1 status code status descriptor
  K1: V1 \ R & lt \ n-
  the Content-the Type: text / html; charset = UTF8; -> tells the browser back is an html file
  \ r \ n
  response body <- HTML content
essentially 2.Python web frame in
  a message transceiver socket -> according to the HTTP protocol message format to parse the message

  The correspondence relationship between the path b and the function to be performed -> main business logic

  . C string substitution -> Template Language (replaced by special symbol data)

3. A complete web request process:
  1. In the browser address bar enter the URL, to establish a connection with the server, the browser sends a request
  2 server receives the message, parses the request message
  3. To execute the function, open the HTML file character Alternatively string, to give a final HTML content to be returned
  4. the message format of claim HTTP protocol, the HTML content to the user's browser to reply (response transmission)
  5. When the browser receives a response message, in accordance with the rules of rendering HTML page
  6. close the connection

Django 4.
  1.Django project startup
  command line to start python manage.py runserver IP: port
  directly inside the IDE runs a small green triangle where there was a set

2. Configure relevant
  in settings.py file
  1. Templates (storage configuration HTML file) -> tell Django where to go to find my HTML file
  2. Static configuration file name when naming variables need to follow the format of the Django framework (CSS / JS / picture)
  STATICFILES_DIRS = [os.path.join (base_dir, 'filename')]
3. settings.py to comment out the
  # 'django.middleware.csrf.CsrfViewMiddleware'

Guess you like

Origin www.cnblogs.com/wuyiyuan/p/12022207.html