The question of the separation of the front and rear ends

recently, I was learning the flask framework. When I came into contact with the concept of "separation of front and rear ends", I was very curious. I checked on the Internet and said that the front and rear ends exchange data through JSON. My personal experience is quite general. Can anyone take flask as an example to explain the separation of front and back ends of writing? I don"t appreciate it.

Mar.03,2021

Front and rear separation has nothing to do with the framework. The subject should have a vague understanding of the concept of front and rear separation. Let me explain briefly.

  1. the front and rear ends are not separated.
    usually the front end and the background code are coupled together and placed in the same project. Normally, cross-domain is not involved. The server directly returns the complete html to be rendered by the browser.

  2. jsonjson

generally speaking, the front and rear end is decoupled. The front end can be deployed to a static server to run independently, and when data is needed, AJAX accesses the corresponding interface provided by the back end to get things.


the advantage of front-end separation is that the front-end development technology has a relatively high degree of freedom in choosing the front-end development technology, and is no longer limited by the back-end development technology. What we should pay attention to is the cooperation of interface design and API joint adjustment before development, if the organization is not good, the overall efficiency will be relatively low.

the main change is that the server does not output html files, but only provides rest interfaces to obtain data, usually in json format. The embodiment of
in flask is that you don't use Jinja2 template files.

the front end generally uses the technical system of nodejs. In more complex cases, nodejs server will be independent and can do the first screen rendering, unified data format processing and other work.

Menu