API

  • GET → as usual! Read a data
  • POST → as usual! Create, Update, Delete data

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) } })

--

--

Extract the desired data using OPEN API

The point (JQUERY)

CLICK ▶Get INPUT values
: let txt = $(‘#INPUT values’).val();

  • check : console.log(txt)

Include specific letter
: txt.includes(‘txt’)

Extract txt(ex.domain)
: txt.split(‘@’)[1].split(‘.’)[0]
(EX.hello.gmail.com > gmail)

Append txt
: $(‘#id’).append(txt)

The point (AJAX)

🟣AJAX Frame(‘get’)

$.ajax({
type: “GET”,
url: “URL”,
data: {},
success: function(response){
}
})’

Change the img src
: $(‘#id’).attr(‘src’,imgurl*)

*let imgurl = response[0][‘url’]

Loading▶Action
$(document).ready(function () {
get_rate();
});

--

--