CHRISDANIEL145 commited on
Commit ·
8fa9f74
1
Parent(s): 1cc76b1
Fix static file serving for Hugging Face deployment
Browse files- Dockerfile +9 -1
- app.py +28 -8
Dockerfile
CHANGED
|
@@ -13,10 +13,18 @@ RUN pip install --no-cache-dir -r requirements.txt
|
|
| 13 |
|
| 14 |
# Copy application files
|
| 15 |
COPY app.py .
|
| 16 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
|
| 18 |
# Expose port 7860 (Hugging Face default)
|
| 19 |
EXPOSE 7860
|
| 20 |
|
|
|
|
|
|
|
|
|
|
| 21 |
# Run Flask app
|
| 22 |
CMD ["python", "app.py"]
|
|
|
|
| 13 |
|
| 14 |
# Copy application files
|
| 15 |
COPY app.py .
|
| 16 |
+
|
| 17 |
+
# Copy static folder with all contents
|
| 18 |
+
COPY static/ ./static/
|
| 19 |
+
|
| 20 |
+
# Debug: List files to verify copy
|
| 21 |
+
RUN ls -la && ls -la static/ && ls -la static/assets/ || true
|
| 22 |
|
| 23 |
# Expose port 7860 (Hugging Face default)
|
| 24 |
EXPOSE 7860
|
| 25 |
|
| 26 |
+
# Set environment variable
|
| 27 |
+
ENV FLASK_ENV=production
|
| 28 |
+
|
| 29 |
# Run Flask app
|
| 30 |
CMD ["python", "app.py"]
|
app.py
CHANGED
|
@@ -5,7 +5,7 @@ Deployed: December 2024
|
|
| 5 |
"""
|
| 6 |
|
| 7 |
import os
|
| 8 |
-
from flask import Flask, request, jsonify, send_from_directory
|
| 9 |
from flask_cors import CORS
|
| 10 |
from groq import Groq
|
| 11 |
import json
|
|
@@ -18,7 +18,17 @@ from PyPDF2 import PdfReader
|
|
| 18 |
API_KEY = os.getenv('GROQ_API_KEY', '')
|
| 19 |
GROQ_MODEL = 'llama-3.3-70b-versatile'
|
| 20 |
|
| 21 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 22 |
CORS(app)
|
| 23 |
|
| 24 |
client = None
|
|
@@ -72,30 +82,40 @@ def generate_content_with_groq(prompt):
|
|
| 72 |
# Serve main page - redirect to signup first
|
| 73 |
@app.route('/')
|
| 74 |
def home():
|
| 75 |
-
return
|
| 76 |
|
| 77 |
# Serve dashboard
|
| 78 |
@app.route('/dashboard')
|
| 79 |
@app.route('/index.html')
|
| 80 |
def dashboard():
|
| 81 |
-
return
|
| 82 |
|
| 83 |
# Serve login page
|
| 84 |
@app.route('/login')
|
| 85 |
@app.route('/login.html')
|
| 86 |
def login():
|
| 87 |
-
return
|
| 88 |
|
| 89 |
# Serve signup page
|
| 90 |
@app.route('/signup')
|
| 91 |
@app.route('/signup.html')
|
| 92 |
def signup():
|
| 93 |
-
return
|
| 94 |
|
| 95 |
-
# Serve static assets
|
| 96 |
@app.route('/assets/<path:filename>')
|
| 97 |
def serve_assets(filename):
|
| 98 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 99 |
|
| 100 |
# API Endpoints
|
| 101 |
@app.route('/upload_resume', methods=['POST'])
|
|
|
|
| 5 |
"""
|
| 6 |
|
| 7 |
import os
|
| 8 |
+
from flask import Flask, request, jsonify, send_from_directory
|
| 9 |
from flask_cors import CORS
|
| 10 |
from groq import Groq
|
| 11 |
import json
|
|
|
|
| 18 |
API_KEY = os.getenv('GROQ_API_KEY', '')
|
| 19 |
GROQ_MODEL = 'llama-3.3-70b-versatile'
|
| 20 |
|
| 21 |
+
# Get the directory where app.py is located
|
| 22 |
+
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
|
| 23 |
+
STATIC_DIR = os.path.join(BASE_DIR, 'static')
|
| 24 |
+
|
| 25 |
+
print(f"BASE_DIR: {BASE_DIR}")
|
| 26 |
+
print(f"STATIC_DIR: {STATIC_DIR}")
|
| 27 |
+
print(f"Static dir exists: {os.path.exists(STATIC_DIR)}")
|
| 28 |
+
if os.path.exists(STATIC_DIR):
|
| 29 |
+
print(f"Static contents: {os.listdir(STATIC_DIR)}")
|
| 30 |
+
|
| 31 |
+
app = Flask(__name__, static_folder=STATIC_DIR, static_url_path='/static')
|
| 32 |
CORS(app)
|
| 33 |
|
| 34 |
client = None
|
|
|
|
| 82 |
# Serve main page - redirect to signup first
|
| 83 |
@app.route('/')
|
| 84 |
def home():
|
| 85 |
+
return send_from_directory(STATIC_DIR, 'signup.html')
|
| 86 |
|
| 87 |
# Serve dashboard
|
| 88 |
@app.route('/dashboard')
|
| 89 |
@app.route('/index.html')
|
| 90 |
def dashboard():
|
| 91 |
+
return send_from_directory(STATIC_DIR, 'index.html')
|
| 92 |
|
| 93 |
# Serve login page
|
| 94 |
@app.route('/login')
|
| 95 |
@app.route('/login.html')
|
| 96 |
def login():
|
| 97 |
+
return send_from_directory(STATIC_DIR, 'login.html')
|
| 98 |
|
| 99 |
# Serve signup page
|
| 100 |
@app.route('/signup')
|
| 101 |
@app.route('/signup.html')
|
| 102 |
def signup():
|
| 103 |
+
return send_from_directory(STATIC_DIR, 'signup.html')
|
| 104 |
|
| 105 |
+
# Serve static assets - CSS and JS
|
| 106 |
@app.route('/assets/<path:filename>')
|
| 107 |
def serve_assets(filename):
|
| 108 |
+
assets_dir = os.path.join(STATIC_DIR, 'assets')
|
| 109 |
+
return send_from_directory(assets_dir, filename)
|
| 110 |
+
|
| 111 |
+
# Catch-all for any other static files in root
|
| 112 |
+
@app.route('/<path:filename>')
|
| 113 |
+
def serve_static(filename):
|
| 114 |
+
# Check if file exists in static directory
|
| 115 |
+
file_path = os.path.join(STATIC_DIR, filename)
|
| 116 |
+
if os.path.exists(file_path):
|
| 117 |
+
return send_from_directory(STATIC_DIR, filename)
|
| 118 |
+
return jsonify({'error': 'Not found'}), 404
|
| 119 |
|
| 120 |
# API Endpoints
|
| 121 |
@app.route('/upload_resume', methods=['POST'])
|