Spaces:
Running
Running
import os | |
import subprocess | |
import sys | |
from urllib.parse import quote | |
def main(): | |
token = os.environ.get('GITHUB') | |
if not token: | |
print('Error: GITHUB environment variable not set') | |
sys.exit(1) | |
token_encoded = quote(token, safe='') | |
clone_url = f'https://{token_encoded}@github.com/johnpaulbin/flashcards.git' | |
print(f'Cloning') | |
try: | |
subprocess.run(['git', 'clone', clone_url], check=True) | |
except subprocess.CalledProcessError as e: | |
print(f'Error cloning repository: {e}') | |
sys.exit(1) | |
# Change directory to the cloned repo | |
os.chdir('flashcards') | |
# Run app.py | |
try: | |
subprocess.run(['python', 'app.py'], check=True) | |
except subprocess.CalledProcessError as e: | |
print(f'Error running app.py: {e}') | |
sys.exit(1) | |
if __name__ == '__main__': | |
main() |