需要安装flask :
pip install flask
项目目录结构:
代码:
from flask import Flask
app = Flask(__name__,static_url_path='/static',static_folder='static')
@app.route('/')
def hello_world():
return 'Hello World!'
if __name__ == '__main__':
app.run(host="0.0.0.0",port=8080,debug=True)
这里我们浏览器直接打开网页,就会加载我们静态文件