flask使用get请求传递参数

#后端程序

from flask import Flask,request

app = Flask(__name__)

@app.route('/loginsss')
def hello_world():
    numb = int(request.args.get('numb'))
    numb += 1
    return str(numb)

if __name__ == '__main__':
    app.run()

#前段程序

import requests
url = 'http://127.0.0.1:5000/loginsss'
params = {
    'numb':'4',
}
res = requests.get(url=url,params=params)
print(res.text)

你可能感兴趣的:(flask使用get请求传递参数)