nykadamec commited on
Commit
668dc2e
Β·
1 Parent(s): 18ea579
Files changed (4) hide show
  1. Dockerfile +5 -2
  2. app.py +25 -0
  3. package.json +1 -1
  4. start.sh +14 -0
Dockerfile CHANGED
@@ -15,11 +15,14 @@ RUN apt-get update && apt-get install -y \
15
  COPY package*.json ./
16
 
17
  # Install Node.js dependencies
18
- RUN npm ci --only=production
19
 
20
  # Copy application code
21
  COPY . .
22
 
 
 
 
23
  # Expose port for Hugging Face Spaces
24
  EXPOSE 7860
25
 
@@ -28,4 +31,4 @@ ENV NODE_ENV=production
28
  ENV PORT=7860
29
 
30
  # Start the server
31
- CMD ["npm", "start"]
 
15
  COPY package*.json ./
16
 
17
  # Install Node.js dependencies
18
+ RUN npm install --production
19
 
20
  # Copy application code
21
  COPY . .
22
 
23
+ # Make start script executable
24
+ RUN chmod +x start.sh
25
+
26
  # Expose port for Hugging Face Spaces
27
  EXPOSE 7860
28
 
 
31
  ENV PORT=7860
32
 
33
  # Start the server
34
+ CMD ["./start.sh"]
app.py ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # This file is required for Hugging Face Spaces to recognize this as a valid space
2
+ # The actual application runs in Node.js via Docker
3
+
4
+ import os
5
+ import subprocess
6
+ import sys
7
+
8
+ def main():
9
+ """
10
+ This is a placeholder Python file for Hugging Face Spaces.
11
+ The actual application runs in Node.js via Docker.
12
+ """
13
+ print("πŸš€ AI Image Upscaler API")
14
+ print("This space runs a Node.js application via Docker.")
15
+ print("Please check the Dockerfile and server.js for the actual implementation.")
16
+
17
+ # If running locally, you can start the Node.js server
18
+ if os.path.exists("server.js"):
19
+ print("Starting Node.js server...")
20
+ subprocess.run([sys.executable, "-c", "import subprocess; subprocess.run(['node', 'server.js'])"])
21
+ else:
22
+ print("server.js not found. Please run this in the correct directory.")
23
+
24
+ if __name__ == "__main__":
25
+ main()
package.json CHANGED
@@ -9,7 +9,7 @@
9
  },
10
  "dependencies": {
11
  "express": "^4.18.2",
12
- "multer": "^1.4.5-lts.1",
13
  "cors": "^2.8.5",
14
  "@tensorflow/tfjs": "^4.11.0",
15
  "@tensorflow/tfjs-backend-wasm": "~4.11.0",
 
9
  },
10
  "dependencies": {
11
  "express": "^4.18.2",
12
+ "multer": "^2.0.0-rc.4",
13
  "cors": "^2.8.5",
14
  "@tensorflow/tfjs": "^4.11.0",
15
  "@tensorflow/tfjs-backend-wasm": "~4.11.0",
start.sh ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+
3
+ # Start script for Hugging Face Spaces
4
+ echo "πŸš€ Starting AI Image Upscaler API..."
5
+
6
+ # Check if node_modules exists
7
+ if [ ! -d "node_modules" ]; then
8
+ echo "πŸ“¦ Installing dependencies..."
9
+ npm install --production
10
+ fi
11
+
12
+ # Start the server
13
+ echo "🌟 Starting server on port ${PORT:-7860}..."
14
+ exec node server.js