【发布时间】:2019-04-25 16:01:21
【问题描述】:
我想使用 Flask 框架在 app.py 的 /Project/templates 中托管 3 个文件。这是它的样子。
Project
├── templates
│ ├── index.html
│ ├── index.js
| └── style.css
├── app.py
如何使用 Flask 框架在 app.py 中托管这些文件?这是我的尝试,但它给了我一个空白页。
from flask import Flask, render_template
app = Flask(__name__)
@app.route('/')
def index_html():
return render_template('index.html')
@app.route('/index.js')
def index_js():
return render_template('index.js')
@app.route('/style.css')
def style_css():
return render_template('style.css')
if __name__ == '__main__':
app.run(debug=True)
【问题讨论】:
-
在开发中使用the static folder,在生产中使用您的网络服务器。
标签: javascript python html css flask