| import subprocess | |
| import time | |
| import requests | |
| # Start the Express server as a subprocess | |
| proc = subprocess.Popen(['node', 'server.js'], stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) | |
| # Wait a bit for server to start | |
| time.sleep(2) | |
| try: | |
| # Make a GET request to the server | |
| response = requests.get('http://localhost:3000') | |
| print("Response from JS server:", response.text) | |
| finally: | |
| # Terminate the Node.js server process | |
| proc.terminate() | |
| proc.wait() |