仮想環境を作成していない場合は以下のコマンドで作成
python3 -m venv ./venv
以下のコマンドで仮想環境に入る。作業する時は常に仮想環境に入ること。
source ./venv/bin/activate # 仮想環境に入る
仮想環境に入ったら最初は必要なパッケージをインストールする。(以降は不要)
pip install -r requirements.txt
パッケージがインストールできたら以下のコマンドで実行できる。
./run.sh
3層アーキテクチャを雰囲気だけ採用する。
server.py
templates/
Webサーバーの入出力を担当する層。
- リクエストを受け取る
- リクエストを元にアプリケーション層の関数を呼び、情報を取得・更新する
- 取得した情報を元にレスポンスを作成して送信する
model/
プレゼンテーション層とアプリケーション層間でデータのやり取りをするために使用。
application/
アプリケーションのメイン処理を担当する層。
- プレゼンテーション層から呼び出される
- DBから情報を取得したり更新する
- 必要なら結果を返す
データを扱う層。実際にクエリを発行する処理をコードに切り分けてデータ層と言ったりもするが、今回は単にデータベースが担当する。
- データベースそのまま