get 和 post 示例import json
from flask import Flask, request
from wsgiref.simple_server import make_server
py_service = Flask(__name__) # flask 应用名称
@py_service.route('/hello', methods=['GET'])
def get_person_info():
return 'Hello World'
@py_service.route("/change", methods=['POST'])
def get_separate():
parameters = json.loads(request.data.decode())
sentence = parameters['sentence']
print(sentence)
return sentence + ' -- ' + 'is changed'
if __name__ == '__main__':
server = make_server('127.0.0.1', 9000, py_service)
server.serve_forever()