나의 개발일지(김지헌)
4주차 2 flask 서버 만들기 기본 코드 본문
from flask import Flask
app = Flask(__name__)
@app.route('/')
def home():
return 'This is Home!'
if __name__ == '__main__':
app.run('0.0.0.0',port=5000,debug=True)
사용할시 폴더 만들기
templates - html 담기는것
static - 이미지와 css
templates 에 html 파일 만들고
파이썬 폴더에 붙혀넣기
from flask import Flask, rander_template, request, jsonify
app = Flask(__name__)
@app.route('/')
def home():
return rander_template('html폴더명')
if __name__ == '__main__':
app.run('0.0.0.0',port=5000,debug=True)
$.ajax({
type: "GET",
url: "/test?title_give=봄날은간다",
data: {},
success: function (response) {
console.log(response)
}
})
}
url /test 창구에 가는데 title_give라는 이름으로 봄날은 간다를 가져갈께
@app.route('/test', methods=['GET'])
def test_get():
title_receive = request.args.get('title_give')
print(title_receive)
return jsonify({'result':'success', 'msg': '이 요청은 GET!'})
'코드 및 잡다' 카테고리의 다른 글
버튼 누를시 카운터 올려서 표시하기 (0) | 2022.09.05 |
---|---|
GET,POST 요청하기 html (0) | 2022.09.05 |
GET, POST 요청 하기 app.py (0) | 2022.09.05 |
크롤링 (0) | 2022.09.04 |
화성땅 공동구매 (0) | 2022.09.04 |