Skip to content

ayukat1016/fastapi-reservation

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

fastapi-reservation

  • 本リポジトリはフロンドエンドにstreamlit、バックエンドにFastAPI、データベースにPostgresを使ったハンズオン用の会議室予約アプリです
  • Docker環境とPoetry仮想環境の実行方法と操作方法を記載

Docker環境実行

環境変数

frontendbackendsrc/.envの環境変数を設定 する

バックエンド

# postgresを使わないときはtrueを指定
USE_SQLITE=false

フロントエンド

# docker-compose.yamlのサービス名を指定
BACKEND_URL=http://backend:8000

環境構築

ライブラリ変更時

poetry export --without-hashes -f requirements.txt --output requirements.txt

コードやライブラリの変更発生時

docker compose build

実行方法

コンテナ起動

docker compose up -d

コンテナ停止

docker compose down

フロントエンドのURL

http://localhost:8501

APIエンドポイント

http://localhost:8000/docs

DB操作

docker exec -it postgres bash
# password と入力
root@postgres:/# psql -U postgres reservation -W

Poetry仮想環境実行

環境変数

frontendbackendsrc/.envの環境変数を設定 する

バックエンド

USE_SQLITE=true

フロントエンド

BACKEND_URL=http://localhost:8000

環境構築

新しいディレクトリを使用するときfrontendbackendのディレクトリで仮想環境を構築する

pyenv local 3.9.13
poetry install

実行方法

バックエンド

poetry run uvicorn src.main:app --reload

フロントエンド

poetry run streamlit run src/main.py

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors