AnyaXZero commited on
Commit
6b758b0
·
verified ·
1 Parent(s): a42d4ac

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -1
app.py CHANGED
@@ -14,6 +14,12 @@ def clone_repo():
14
  repo_url = f"https://{GITHUB_USERNAME}:{GITHUB_TOKEN}@github.com/{GITHUB_USERNAME}/{REPO_NAME}.git"
15
  subprocess.run(["git", "clone", repo_url, "repo"], check=True)
16
 
 
 
 
 
 
 
17
  def install_requirements():
18
  req_file = "repo/requirements.txt"
19
  if os.path.exists(req_file):
@@ -24,6 +30,7 @@ def start_script():
24
 
25
  def run_app():
26
  clone_repo()
 
27
  install_requirements()
28
  start_script()
29
 
@@ -33,4 +40,4 @@ def startup_event():
33
 
34
  @app.get("/")
35
  def home():
36
- return {"status": "Repo cloned, requirements installed, start script running 🚀"}
 
14
  repo_url = f"https://{GITHUB_USERNAME}:{GITHUB_TOKEN}@github.com/{GITHUB_USERNAME}/{REPO_NAME}.git"
15
  subprocess.run(["git", "clone", repo_url, "repo"], check=True)
16
 
17
+ def setup_env():
18
+ sample = "repo/.env.sample"
19
+ target = "repo/.env"
20
+ if os.path.exists(sample) and not os.path.exists(target):
21
+ subprocess.run(["cp", sample, target], check=True)
22
+
23
  def install_requirements():
24
  req_file = "repo/requirements.txt"
25
  if os.path.exists(req_file):
 
30
 
31
  def run_app():
32
  clone_repo()
33
+ setup_env() # 👈 added here
34
  install_requirements()
35
  start_script()
36
 
 
40
 
41
  @app.get("/")
42
  def home():
43
+ return {"status": "Repo cloned, env setup, requirements installed, script running 🚀"}