
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','
