设置路由的访问方式get post常用的两种
# -*- coding: utf-8 -*- # Flask hello world from flask import Flask, redirect, request from flask import render_template app = Flask(__name__) @app.route('/send_msg', methods=['GET','POST']) def Messaging(): if request.method =='POST': return('post') elif request.method =='GET': return('get') else: pass @app.route('/send_msg', methods=['POST']) def do_send(): return('post') @app.route('/send_msg', methods=['GET']) def show_form(): return('get') @app.route('/') def hello(): return render_template('forms.html') if __name__ == '__main__': ####默认监听127.0.0.1:5000 关闭调试模式 app.run(host='127.0.0.1',port=8888,debug=True)
代码均是测试代码,相对简单。