(我是想,在构建一个网站,全异步加载。即,用户先载入静态 html 文件,然后利用 jQuery 从服务端通过与 App 相同的 API 载入数据。)
Flask 如何直接输出静态 HTML 文件而不经过渲染?
阿神2017-04-17 13:13:22
Cheek Nao
@app.route('/')
def root():
return app.send_static_file('index.html')
Reference stackoverflow
Reference official documentation
高洛峰2017-04-17 13:13:22
Flask directly creates the output Restful API.
The front-end jQuery can directly request data to render the page.
The front end can also use some js frameworks, such as angular.js and ember.js, etc.
黄舟2017-04-17 13:13:22
You can put the rendering template on the front end
13 JavaScript template engines
PHP中文网2017-04-17 13:13:22
This first loads the static html. In the html, you can use jQuery to call the written REST API to load the data, and then parse the data on the browser side and present it.