例题一
from flask import Flask
app = Flask(__name__)
@app.route('/index')
def index():return f'<h1>这是首页!</h1>'
def second():return f'<h1>这是第二页!</h1>'
if __name__ == '__name__':app.run(host="0.0.0.0",port="5000",debug="trust")
例题二
from flask import Flask
app = Flask(__name__)
def second():return f'<h1>这是首页!</h1>'
def index():return f'<h1>这是第二页!</h1>'
app.add_url_rule(rule='/index',view_func=index)
if __name__ =='__main__':app.run()
例题三
from flask import Flask
app = Flask(__name__)
@app.route('/<page>')
def index(page):return f'<h1>当前为第{page}页</h1>'
if __name__ == '__main__':app.run()
例题四
from flask import Flask
app = Flask(__name__)
@app.route('/<int:page>')
def index(page):return f'<h1>当前为第{page}页</h1>'
if __name__ == '__main__':app.run()