Instantly share code, notes, and snippets.

Embed
What would you like to do?
Responder==1.0.1( http://python-responder.org/ )で作ったアプリをGAE/Python3.7で動かすサンプル
# This file specifies files that are *not* uploaded to Google Cloud Platform
# using gcloud. It follows the same syntax as .gitignore, with the addition of
# "#!include" directives (which insert the entries of the given .gitignore-style
# file at that point).
#
# For more information, run:
# $ gcloud topic gcloudignore
#
.gcloudignore
# If you would like to upload your .git directory, .gitignore file or files
# from your .gitignore file, remove the corresponding line
# below:
.git
.gitignore
# Python pycache:
__pycache__/
# Ignored by the build system
/setup.cfg
# Pipenv
Pipfile
Pipfile.lock
runtime: python37
entrypoint: uvicorn --host 0.0.0.0 --port $PORT main:api
<!DOCTYPE html>
<html lang="ja">
<head>
<!-- このファイルはプロジェクト直下に作ったtemplatesディレクトリの下に置く -->
<meta charset="UTF-8">
<title>Hello, World!</title>
<link href="/static/css/main.css" rel="stylesheet" type="text/css" media="all">
</head>
<body>
<h1>Hello, World!</h1>
</body>
</html>
The MIT License (MIT)
Copyright (c) 2018 Tsutsui, Ryuji
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
/* このファイルはプロジェクト直下に作ったstatic/cssディレクトリの下に置く */
body {
background: #eeeeee;
}
from pathlib import Path
import responder
BASE_DIR = Path(__file__).parent
api = responder.API(
static_dir=str(BASE_DIR.joinpath('static')),
templates_dir=str(BASE_DIR.joinpath('templates')),
)
@api.route("/")
async def greet_world(req, resp):
resp.text = api.template('index.html')
if __name__ == '__main__':
api.run(port=8080)
-i https://pypi.org/simple
aiofiles==0.4.0
aniso8601==3.0.2
apispec==1.0.0b3
apistar==0.6.0
asgiref==2.3.2
async-timeout==3.0.1
certifi==2018.10.15
chardet==3.0.4
click==7.0
docopt==0.6.2
graphene==2.1.3
graphql-core==2.1
graphql-relay==0.4.5
graphql-server-core==1.1.1
h11==0.8.1
httptools==0.0.11
idna==2.7
itsdangerous==1.1.0
jinja2==2.10
markupsafe==1.0
marshmallow==3.0.0b19
parse==1.9.0
promise==2.2.1
python-multipart==0.0.5
pyyaml==4.2b4
requests-toolbelt==0.8.0
requests==2.20.0
responder==1.0.1
rfc3986==1.1.0
rx==1.6.1
six==1.11.0
starlette==0.5.5
urllib3==1.24
uvicorn==0.3.16
uvloop==0.11.2 ; sys_platform != 'win32'
websockets==6.0
whitenoise==4.1
@ryu22e

This comment has been minimized.

Owner

ryu22e commented Oct 27, 2018

デプロイはGoogle Cloud SDKをインストールした環境でgcloud app deployを実行。

Pipenvを使いたいならプロジェクト直下に以下の内容のPipfileを置いて、pipenv install && pipenv lock -r > requirements.txtを実行する。

[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"

[packages]
responder = "*"

[requires]
python_version = "3.7"

[pipenv]
allow_prereleases = true
@manatlan

This comment has been minimized.

manatlan commented Nov 8, 2018

Hi ...

Are you saying that you reach to run an ASGI app on the Google AppEngine python37 STANDARD ENV (2nd generation) ?
Is your responder working on an appspot instance ???

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment