サーバ側
from flask import Flask, request, jsonify
app = Flask(__name__)
@app.route('/EmployeeSystem', methods=['POST'])
def register():
data = request.get_json()
id = data.get('id')
name = data.get('name')
data = {
f"id: {id}, name: {name}"
}
return jsonify(data), 200
if __name__ == '__main__':
app.run(host="0.0.0.0")
リクエスト側
import requests
url = 'http://127.0.0.1:5000/EmployeeSystem'
data = {
'id': 1,
'name': '小林'
}
response = requests.post(url, json=data)
print("Response from server:", response.json())
print("Status code:", response.status_code)
レスポンスコードの表示