from flask import Flask, request
from flask_restful import Resource, Api
from flask_restful.reqparse import RequestParser
app = Flask(__name__)
api = Api(app)
class RemoteData(Resource):
def post(self):
parser = RequestParser()
parser.add_argument('type')
parser.add_argument('body')
# 默认会从查询字符串、post键值对、post-json数据进行参数提取
args = parser.parse_args()
print(args.type)
print(args.body)
return {'code': 200}
api.add_resource(RemoteData, '/get_json')
if __name__ == '__main__':
app.run(port=8080, debug=False)