johnpaulbin commited on
Commit
0c3cfb8
1 Parent(s): 60ae9ad

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +32 -0
app.py ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import subprocess
3
+ import sys
4
+ from urllib.parse import quote
5
+
6
+ def main():
7
+ token = os.environ.get('GITHUB')
8
+ if not token:
9
+ print('Error: GITHUB environment variable not set')
10
+ sys.exit(1)
11
+ token_encoded = quote(token, safe='')
12
+ clone_url = f'https://{token_encoded}@github.com/johnpaulbin/flashcards.git'
13
+
14
+ print(f'Cloning')
15
+
16
+ try:
17
+ subprocess.run(['git', 'clone', clone_url], check=True)
18
+ except subprocess.CalledProcessError as e:
19
+ print(f'Error cloning repository: {e}')
20
+ sys.exit(1)
21
+ # Change directory to the cloned repo
22
+ os.chdir('flashcards')
23
+
24
+ # Run app.py
25
+ try:
26
+ subprocess.run(['python', 'app.py'], check=True)
27
+ except subprocess.CalledProcessError as e:
28
+ print(f'Error running app.py: {e}')
29
+ sys.exit(1)
30
+
31
+ if __name__ == '__main__':
32
+ main()