Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
import os
|
| 3 |
+
import subprocess
|
| 4 |
+
import sys
|
| 5 |
+
|
| 6 |
+
print("Starting FastSD CPU please wait...")
|
| 7 |
+
|
| 8 |
+
# Check for Python3
|
| 9 |
+
try:
|
| 10 |
+
subprocess.run(["python3", "--version"], capture_output=True, check=True)
|
| 11 |
+
python_command = "python3"
|
| 12 |
+
except subprocess.CalledProcessError:
|
| 13 |
+
# If python3 not found, check for python
|
| 14 |
+
try:
|
| 15 |
+
subprocess.run(["python", "--version"], capture_output=True, check=True)
|
| 16 |
+
python_command = "python"
|
| 17 |
+
except subprocess.CalledProcessError:
|
| 18 |
+
print("Error: Python not found, please install python 3.8 or higher and try again")
|
| 19 |
+
sys.exit(1)
|
| 20 |
+
|
| 21 |
+
print(f"Found {python_command} command")
|
| 22 |
+
|
| 23 |
+
# Get Python version
|
| 24 |
+
python_version = subprocess.run(
|
| 25 |
+
[python_command, "--version"],
|
| 26 |
+
capture_output=True,
|
| 27 |
+
text=True
|
| 28 |
+
).stdout.split()[1]
|
| 29 |
+
print(f"Python version: {python_version}")
|
| 30 |
+
|
| 31 |
+
# Get base directory
|
| 32 |
+
basedir = os.getcwd()
|
| 33 |
+
|
| 34 |
+
# Run the application
|
| 35 |
+
subprocess.run([python_command, "src/app.py", "--api"], check=True)
|