下面是我要运行的应用程序的代码:
from flask import Flask, request, render_template
import json
import requests
import socket
from datetime import datetime
import pickle
import time
import pandas as pd
import numpy as np
@app.route('/index.html')
def index():
return render_template('index.html')
@app.route('/tables.html')
def tables():
return render_template('tables.html')
@app.route('/flot.html')
def flot():
return render_template('flot.html')
@app.route('/morris.html')
def morris():
return render_template('morris.html')
@app.route('/forms.html')
def forms():
return render_template('forms.html')
@app.route('/panels-wells.html')
def panelswells():
return render_template('panels-wells.html')
@app.route('/buttons.html')
def buttons():
return render_template('buttons.html')
@app.route('/notifications.html')
def notifications():
return render_template('notifications.html')
@app.route('/typography.html')
def typography():
return render_template('typography.html')
@app.route('/icons.html')
def icons():
return render_template('icons.html')
@app.route('/blank.html')
def blank():
return render_template('blank.html')
@app.route('/login.html')
def login():
return render_template('login.html')
if __name__ == '__main__':
app.run(host='0.0.0.0', port=8080, debug=True, threaded=True)
pass
以下是我的运行方式:
^{2}$当我点击了以下网址:http://0.0.0.0:8080
甚至http://0.0.0.0:8080/index.html
之后,我看到了以下屏幕:
好心的,帮助我我所缺少的。我在templates
文件夹中有html
模板。请参见图片:
请告诉我。在
试试127.0.0.1:8080,0.0.0.0:8080只是表示应用程序正在监听所有连接
这里有很多问题。在
0.0.0.0
不是您放入浏览器中的地址;它是一个特殊值,用于告诉服务器绑定到任何地址。您需要通过本地主机IP访问站点,这是127.0.0.1:8080
。在其次,您没有在Flask代码中为根路径定义路由处理程序;您只定义了“索引.html”等等。我怀疑您误会了那里发生的事情;路径是您放入浏览器中的内容,它与您呈现的模板没有任何关系。为
/
定义一个路由是非常可能的(也是更好的),但是处理程序要呈现“索引.html“:相关问题 更多 >
编程相关推荐