第一种:
from flask import Flask, render_template
app = Flask(__name__)
@app.route('/')
def fl():
return render_template('index.html')
if __name__ == '__main__' :
app.run(host='127.0.0.1',port=1000,debug=True)
现在登陆这个网址,你就能看到你的html了
如果第一种方法不行的话,试试第二种:
from flask import Flask
app = Flask(__name__)
file = open('index.html','r')
@app.route('/')
def fl():
return file.read()
if __name__ == '__main__' :
app.run(host='127.0.0.1',port=1000,debug=True)
现在再登陆这个网址,你就能看到你的html了
如果程序报错的话,请在评论描述你的错误谢谢