HALU-HAL commited on
Commit
ae2c764
·
1 Parent(s): a7e42cb

[refactor] app.pyにおけるカスタムCSSファイルの生成と保存処理を改善

Browse files

app.pyファイルにおいてカスタムCSSファイルの生成と保存の処理を改善しました:

- **追加された機能**:
- `os`モジュールをインポートしてファイルシステム操作を行うためのAPIを利用可能にしました。

- **変更の詳細**:
- `/custom_style.css`の保存場所をローカルの一時ディレクトリ`/tmp_TimeLinR`に変更し、このディレクトリが存在しない場合には作成するようにしました。
- カスタムCSSファイルの保存場所を変更することで、デプロイ環境に依存しない一時保存場所を確保し、ファイルの管理をより効率的に行えるようになりました。

この変更により、アプリケーションが生成する一時ファイルの管理が容易になり、環境に左右されることなく一貫した動作が期待できます。また、ディレクトリの動的な生成をサポートすることで、アプリケーションの柔軟性と耐障害性が向上しました。

Files changed (1) hide show
  1. app.py +4 -1
app.py CHANGED
@@ -8,6 +8,7 @@ hti = Html2Image()
8
  from modules.create_custom_css_file import create_custom_css_file
9
  from modules.timeline import generate_timeline_html
10
  from config import config
 
11
 
12
  st.set_page_config(layout="wide")
13
  hti = Html2Image()
@@ -49,7 +50,9 @@ def generate_timeline(df, margin_coefficient):
49
  return timeline_html
50
 
51
  def create_custom_css(border_color, marker_color, box_background):
52
- css_file_path = create_custom_css_file(border_color, marker_color, box_background, '/custom_style.css')
 
 
53
  custom_css = load_css(css_file_path)
54
  st.markdown(f'<style>{custom_css}</style>', unsafe_allow_html=True)
55
  return custom_css
 
8
  from modules.create_custom_css_file import create_custom_css_file
9
  from modules.timeline import generate_timeline_html
10
  from config import config
11
+ import os
12
 
13
  st.set_page_config(layout="wide")
14
  hti = Html2Image()
 
50
  return timeline_html
51
 
52
  def create_custom_css(border_color, marker_color, box_background):
53
+ os.makedirs("/tmp_TimeLinR", exist_ok=True)
54
+
55
+ css_file_path = create_custom_css_file(border_color, marker_color, box_background, '/tmp_TimeLinR/custom_style.css')
56
  custom_css = load_css(css_file_path)
57
  st.markdown(f'<style>{custom_css}</style>', unsafe_allow_html=True)
58
  return custom_css