模板實例化需要導入 `render_template`方法
```
from flask import render_template
```
通過 `render_template` 我們可以直接渲染模板輸出
```
return render_template("index.html")
```
示例:
改造下 `app/api_1_0/controller` 下的 `index.py` 控制器使其渲染模板輸出
```
#!/usr/bin/env?python3
#?-*-?encoding:?utf-8?-*-
from?app.api_1_0?import?bp
from?flask?import?render_template
@bp.route('/',?methods=['GET'])
def index():
return?render_template("api/index.html")
```
在 `app/templates/api` 目錄下新建 `index.html` ,錄入如下代碼
```
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Flask</title>
</head>
<body>
<h1>Hello Flask!!!</h1>
</body>
</html>
```
測試
