バックエンド (Python)
- Python: 3.9.x
- FastAPI (フレームワーク): v0.65.2
フロント (CSS と JavaScript)
- bootstrap: v5.0.2
公式ドキュメントにしたがって仮想環境を構築していきます。
まずは現状の python のバージョンをチェックしましょう。
❯ python -V
Python 2.7.16
❯ python3 -V
Python 3.9.5
❯ python3 -m venv venv
❯ ls
README.md venv
❯ source venv/bin/activate
❯ python -V
Python 3.9.5
❯ python3 -V
Python 3.9.5
❯ deactivate
❯ python -V
Python 2.7.16
❯ python3 -V
Python 3.9.5
from fastapi import FastAPI
app = FastAPI()
@app.get("/")
def root():
return {"message": "Hello World"}
起動する。
❯ uvicorn main:my_app --reload
http://localhost:8000 にアクセスする。
さらに http://localhost:8000/docs にアクセスする。
❯ pytest -vvvs --cov=./ --cov-config=../.coveragerc --cov-report=term-missing unit_test --disable-pytest-warnings
https://docs.sqlalchemy.org/en/14/tutorial/engine.html
❯ curl -X POST http://localhost:9090/-/reload
❯ docker build ./app -t fastapi-todo-app
❯ docker images | grep fastapi-todo-app
fastapi-todo-app latest 2bf123e25958 2 minutes ago 184MB