[DEVELOPMENT/CODNING]#04. PHYTHON

API

How to receive data from clients

GET-API CODE

@app.route(‘/test’, methods=[‘GET’]) def test_get(): title_receive = request.args.get(‘title_give’) print(title_receive) return jsonify({‘result’:’success’, ‘msg’: ‘이 요청은 GET!’})

CHECK GET-Ajax CODE

$.ajax({ type: “GET”, url: “/test?title_give=봄날은간다”, data: {}, success: function(response){ console.log(response) } })

POST-API CODE

@app.route(‘/test’, methods=[‘POST’]) def test_post(): title_receive = request.form[‘title_give’] print(title_receive) return jsonify({‘result’:’success’, ‘msg’: ‘이 요청은 POST!’})

CHECK POST-Ajax CODE

$.ajax({ type: “POST”, url: “/test”, data: { title_give:’봄날은간다’ }, success: function(response){ console.log(response) } })

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store