Flask
폴더 설정
app.py
from flask import Flask, render template app = Flask(__name__) @app.route('/') def home(): return render_template('index.html') if __name__ == '__main__': app.run('0.0.0.0',port=5000,debug=True)
- http://localhost:5000/
- @app.route('/') 페이지 구분
GET
GET 요청 API
@app.route('/test', methods=['GET']) def test_get(): title_receive = request.args.get('title_give') print(title_receive) return jsonify({'result':'success', 'msg': '이 요청은 GET!'})
GET 요청 확인 Ajax
$.ajax({ type: "GET", url: "/test?title_give=봄날은간다", data: {}, success: function(response){ console.log(response) } }
POST
POST 요청 API
@app.route('/test', methods=['POST']) def test_post(): title_receive = request.form['title_give'] print(title_receive) return jsonify({'result':'success', 'msg': '이 요청은 POST!'})
POST 요청 확인 Ajax
$.ajax({ type: "POST", url: "/test", data: { title_give:'봄날은간다' }, success: function(response){ console.log(response) } }
meta 태그
책리뷰 사이트 (제목, 저자, 코멘트 제출 시 mongodb에 저장하여 테이블에 행 추가)
영화 메모장 (영화 url, 코멘트 제출 시 mongodb에 저장하여 메타정보 포함 카드 추가)