Skip to content

Instantly share code, notes, and snippets.

@lulichn
Last active June 24, 2021 02:30
Show Gist options
  • Save lulichn/8fd18a4ed9f74b9080e2d32c7c28140a to your computer and use it in GitHub Desktop.
Save lulichn/8fd18a4ed9f74b9080e2d32c7c28140a to your computer and use it in GitHub Desktop.
Cloud9 - python

環境構築

Python 3.8.x のインストール

Poetryのインストール

poetry は requirements.txtの 出力のみに利用する

$ curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/install-poetry.py | python -

FIXME: poetry の virtualenv の環境を指定して実行する方法が分からないので

アプリケーションの実行

秘密鍵の設定 (更新するためには)

Git Repository に接続するための鍵を配置する.

ソースコードの取得

画面左端の Source Control か, terminal でプロジェクトを Clone する.

$ git clone https://github.com/lulichn/fastapi-sample.git

依存のインストール

$ poetry export -f requirements.txt > requirements.txt
$ pip3 install -r requirements.txt

.envの設定

https://github.com/lulichn/fastapi-sample#local-development

実行

main.py を開き, メニューから Run -> Run With -> Python3

失敗するので, CWD を指定して再実行する.

SS 2021-06-07 10 23 54

FIXME: 開発中のディレクトリを既定のWorking Dirに設定するなどできないか?

ブラウザプレビュー

メニューから Preview -> Preview Running Application

NOTE: AWS Cloud9 Integrated Development Environment (IDE) で実行中のアプリケーションのプレビュー

SS 2021-06-07 10 36 34

デバッグ

デバッガのインストール

$ pip3 install ikp3db

デバッグ実行

起動オプションでデバッグを有効にする.

if __name__ == "__main__":
    uvicorn.run(app, port=8080, debug=True)

虫マークを有効にする.

SS 2021-06-07 10 28 06

Breakpointを設定し動作することを確認する.

SS 2021-06-07 10 31 51

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