설정, 간단히 정리
python 설치
flask 설치
pip install -U flask
vscode 설치
virtualenv 설치 (venv이 경량화 버전, 그러므로 virtualenv사용)
venvpip install -U virtualenv
flask 서버 구동
GET, POST 방식 확인  # save this as app.py
  from flask import Flask, make_response
  from flask import request
  app = Flask(__name__)
  user = "newUser"
  password = "password"
  headers = {'content-type', 'application/json'}
  @app.route("/", methods=['GET','POST'])
  def index():
      print(request.method)
      if request.method == 'GET':
          # query string 가져오는거
          name = request.args.get('name')
          print(f'request: {request}')
          return f'Index Page, name:{name}'
      elif request.method == 'POST':
          json = request.json
          key1 = request.form.get("key1")
          print(f'결과: {key1}')
          # print(f'request: {request["number"]}')
          return f"\n{request.form}\n{request.json}"
  @app.route("/hello")
  def hello():
      return "Hello, World!"
  if __name__ == '__main__':
  #   app.run(debug=True, host='0.0.0.0', port=3000)
    app.run(host='0.0.0.0', port=3000)
curl -d '{"key1":"value1", "key2":"value2"}' -H "Content-Type: application/json" -X POST http://localhost:3000
vscode, flask 디버깅 모드 설정interpreter은 virtualenv 사용"justMyCode":falselaunch.json 설정{
  // Use IntelliSense to learn about possible attributes.
  // Hover to view descriptions of existing attributes.
  // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
  "version": "0.2.0",
  "configurations": [
      {
          "name": "Python: Flask",
          "type": "python",
          "request": "launch",
          "module": "flask",
          "env": {
              "FLASK_APP": "app.py",
              "FLASK_DEBUG": "1"
          },
          "args": [
              "run",
              "--no-debugger",
              "--no-reload"
          ],
          "jinja": true,
          "justMyCode": false
      }
  ]
}400 Bad request. The browser (or proxy) sent a request that this server could not understand.
파라미터 json 데이터 확인 이후 조작하기