service request packet flask micro structures (pile simulation tests)

from flask import Flask,request
import json

= the Flask App (name__ __)
@ app.route ( '/ outsideWeb / Integration / qryUserActivity.sync', Methods = [ 'the GET', 'the POST']) # define routes (resource request url address path), the request method may get / post
DEF args ():
Mobile = request.args.get ( "Mobile") # acquisition parameters in the URL request, mobile in a request url parameters Key
name = request.form.get ( "name") # post requests Get body parameters, name as the key parameter in the request body
todos = json.dumps ({# type must be returned as return type str, need to first cast about dict
"qry_user_activity_rsp": [
{ "END_DATE": "2019- 00:00:00 06-09 ",
" eparchy_code ":" 003 ", 
" Mobile ": Mobile, #mobile value request from the resource
" action_name ":"Chang gear 108 yuan more ice cream ",
" START_DATE ":" 2019-05-08 11:50:36 "}],
" resp_desc ":" Successful Operation ",
"resp_code": "0"})
return todos

__name__ __ == IF '__ main__':
app.run (Host = '0.0.0.0', Port = '8080', Debug = True) # Host = '0.0.0.0' represents the open access to other machines, '8080' to visit port, debug = True indicates that the print debug log

# Request URL address: http: //127.0.0.1:? 8080 / outsideWeb / integration / qryUserActivity.sync mobile = 15013440000 & id = 123456

 

Guess you like

Origin www.cnblogs.com/whitemouseV2-0/p/10990867.html