커뮤니티
포인트
쿠폰
내 강의실
국비 신청 내역
증명서
계정
로그아웃
학습 질문
개발 일지
나의 활동
답변 완료
local host 실행 중 Syntax error
undefined주차
북마크
이*우
댓글
2
추천
0
조회수
8
조회수
8
답변 완료

from flask import Flask, render_template, request, jsonify

app = Flask(__name__)


@app.route('/')

def home():

return render_template('index.html')


@app.route("/mars", methods=["POST"])

def mars_post():

sample_receive = request.form['sample_give']

print(sample_receive)

return jsonify({'msg':'POST 연결 완료!'})


@app.route("/mars", methods=["GET"])

def mars_get():

return jsonify({'msg':'GET 연결 완료!'})


if __name__ == '__main__':

app.run('0.0.0.0', port=5001, debug=True)


Mac에서 위 코드를 실행할 때마다 아래 오류가 나옵니다.


(venv) Sangs-MacBookPro:02. mars sangwoolee$ #@app.route("/mars", methods=["POST"])

(venv) Sangs-MacBookPro:02. mars sangwoolee$ #def mars_post():

(venv) Sangs-MacBookPro:02. mars sangwoolee$ #  sample_receive = request.form['sample_give']

(venv) Sangs-MacBookPro:02. mars sangwoolee$ #  print(sample_receive)

(venv) Sangs-MacBookPro:02. mars sangwoolee$ #  return jsonify({'msg':'POST 연 결 완료!'})

(venv) Sangs-MacBookPro:02. mars sangwoolee$ 

(venv) Sangs-MacBookPro:02. mars sangwoolee$ @app.route("/mars", methods=["GET"])

bash: syntax error near unexpected token `"/mars",'

(venv) Sangs-MacBookPro:02. mars sangwoolee$ def mars_get():

bash: syntax error near unexpected token `('

(venv) Sangs-MacBookPro:02. mars sangwoolee$   return jsonify({'msg':'GET 연결 완료!'})

bash: syntax error near unexpected token `('

(venv) Sangs-MacBookPro:02. mars sangwoolee$ 

(venv) Sangs-MacBookPro:02. mars sangwoolee$ if __name__ == '__main__':

>   app.run('0.0.0.0', port=5001, debug=True)

bash: syntax error near unexpected token `'0.0.0.0','


취소
 공유
취소
댓글 0
댓글 알림
나의얼굴