본문 바로가기

post8

4-14 4주차 마무리 연습_ 팬명록 1) 응원 남기기(POST): 정보 입력 후 '응원 남기기' 버튼클릭 시 주문목록에 추가 2) 응원 보기(GET): 페이지 로딩 후 하단 응원 목록이 자동으로 보이기 완성본: http://spartacodingclub.shop/web/homework 완성코드: app.py from flask import Flask, render_template, request, jsonify app = Flask(__name__) from pymongo import MongoClient client = MongoClient("내 URL") db = client.sparta @app.route('/') def home(): return render_template('index.html') @app.route("/homew.. 2022. 5. 23.
4-11 [스파르타피디아] - 뼈대 준비하기 app.py 코드 from flask import Flask, render_template, request, jsonify app = Flask(__name__) @app.route('/') def home(): return render_template('index.html') @app.route("/movie", methods=["POST"]) def movie_post(): sample_receive = request.form['sample_give'] print(sample_receive) return jsonify({'msg':'POST 연결 완료!'}) @app.route("/movie", methods=["GET"]) def movie_get(): return jsonify({'msg':'GE.. 2022. 5. 21.
Flask_API GET/POST 요청 / 요청확인 코드 ▶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 요청 API코드 @app.route('/test', methods=['POST']) def test_post().. 2022. 5. 20.
서버 / HTTP 서버? 요청을 받으면 요청한 내용을 보내주는 프로그램. HTTP? 서버와 클라이언트가 소통을 하기 위해서 이용하는 방법 대표적으로 GET, POST, PUT, DELETE 방법이있다. 1. GET (읽기) 서버로 부터 데이터를 가져와서 보여줌 예) www.naver.com을 치면 네이버 웹페이지를 서버에서 가져와 보여줌 2. POST(쓰기) 서버에 데이터를 추가, 작성 등 예) 블로그 포스트작성, 댓글작성 3. PUT(수정) 서버의 데이터를 갱신, 작성 예) 블로그 작성글 수정, 업데이트 4. DELETE(삭제) 서버의 데이터를 삭제 예)블로그 포스팅 삭제 그래서!!! 코드짤때 코드에 사용자가 /list라는 페이지를 GET요청하면 거기 해당되는 list.html이라는 파일을 보내줘 라는 코드로 서버에 요.. 2022. 5. 19.