实现简单功能hello world
index.html文件(要求存放于templates文件夹)
<!DOCTYPE html>
<html lang='en'>
<head>
<meta charset="utf-8" />
<title>Hello world!</title>
</head>
<body>
Hello world!
</body>
</html>
应用文件
#!/usr/bin/env python
import flask
# Create the application.
APP = flask.Flask(__name__)
@APP.route('/')
def index():
return flask.render_template('index.html') ## 此处的html文件无需指定位置,自动读取templates文件夹
if __name__ == '__main__':
APP.debug=True
APP.run()