필수 파일 및 구성

프로젝트에는 최소한 다음 파일이 포함되어야 합니다.

파일 및 위치 설명
/src/<your_api_class>.py 백엔드 API가 포함된 클래스 파일(또는 여러 클래스에서 API를 구현하는 경우 여러 파일)입니다.
/src/<your_api_server>.py API 클래스 내에 포함하지 않을 경우 API 서버 코드를 포함하는 선택적인 파일입니다.
/src/app.yaml App Engine 구성에 필요한 웹 앱 배포 설명자입니다.

이러한 각 필수 파일의 콘텐츠는 다음 섹션에서 설명합니다.

API 클래스 파일

클래스 파일(멀티클래스 API를 사용하는 경우 여러 파일)의 필수 및 선택적 콘텐츠는 Endpoints API 만들기 항목에서 자세히 설명합니다.

API 서버 파일

이 파일 및 해당 콘텐츠는 웹 서버 만들기에서 자세히 설명합니다.

app.yaml

이 파일에 필요한 최소 콘텐츠는 다음과 같습니다.

# Copyright 2021 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

runtime: python27
threadsafe: true
api_version: 1
basic_scaling:
  max_instances: 2

skip_files:
- ^(.*/)?#.*#$
- ^(.*/)?.*~$
- ^(.*/)?.*\.py[co]$
- ^(.*/)?.*/RCS/.*$
- ^(.*/)?\..*$
- ^(.*/)?setuptools/script \(dev\).tmpl$

handlers:
# The endpoints handler must be mapped to /_ah/api.
- url: /_ah/api/.*
  script: main.api

libraries:
- name: pycrypto
  version: 2.6
- name: ssl
  version: 2.7.11

env_variables:
  # The following values are to be replaced by information from the output of
  # 'gcloud endpoints services deploy swagger.json' command.
  ENDPOINTS_SERVICE_NAME: YOUR-PROJECT-ID.appspot.com
  ENDPOINTS_SERVICE_VERSION: 2016-08-01r0

각 매개변수는 다음과 같습니다.

  • main은 API 서버의 Python 모듈 및 변수 이름입니다.
  • threadsafe는 App Engine이 여러 요청을 병렬로 전송하도록 하려면 true로 설정하고, App Engine이 요청을 직렬로 전송하도록 하려면 false로 설정합니다.

선택적인 추가 설정을 사용할 수 있습니다. 자세한 내용은 app.yaml 참조에서 확인하세요. 단, 로그인 또는 관리자 상태 요구보안 URL의 정보는 백엔드 API에는 적용되지 않습니다.