CoolFace
Apppublic

AK-21/Graphite-Industrial-Intelligence

sourceHugging Faceupdated 3mo agoView on Hugging Face
0likes
app.py38 linesDownload Raw Back to root
1import os2import subprocess3import sys4 5def main():6    print("--- Bootstrapping Node.js Application on Hugging Face Spaces ---")7 8    # 1. Set HF required port9    os.environ['PORT'] = '7860'10    os.environ['VITE_API_URL'] = '' # Force relative paths for frontend11 12    # 2. Build the React Client13    print("Installing client dependencies...")14    client_dir = os.path.join(os.getcwd(), 'client')15    subprocess.run(['npm', 'install'], cwd=client_dir, check=True)16    17    print("Building React frontend...")18    subprocess.run(['npm', 'run', 'build'], cwd=client_dir, check=True)19 20    # 3. Setup the Node Server21    print("Installing server dependencies...")22    server_dir = os.path.join(os.getcwd(), 'server')23    subprocess.run(['npm', 'install'], cwd=server_dir, check=True)24    25    # 4. Start the Server26    print("Starting backend server on port 7860...")27    process = subprocess.Popen(28        ['npx', 'tsx', 'src/index.ts'], 29        cwd=server_dir,30        env=os.environ31    )32    33    # Keep the Python process alive while the Node server runs34    process.wait()35 36if __name__ == "__main__":37    main()38