Spaces:
				
			
			
	
			
			
		Sleeping
		
	
	
	
			
			
	
	
	
	
		
		
		Sleeping
		
	
		fahadcr14
		
	commited on
		
		
					Commit 
							
							·
						
						7b26e4e
	
1
								Parent(s):
							
							f678a54
								
test
Browse files- Dockerfile +20 -0
 - app.py +23 -0
 - templates/index.html +12 -0
 
    	
        Dockerfile
    ADDED
    
    | 
         @@ -0,0 +1,20 @@ 
     | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
| 
         | 
|
| 1 | 
         
            +
            # Use a lightweight Python base image
         
     | 
| 2 | 
         
            +
            FROM python:3.8-slim
         
     | 
| 3 | 
         
            +
             
     | 
| 4 | 
         
            +
            # Set environment variables
         
     | 
| 5 | 
         
            +
            ENV PYTHONDONTWRITEBYTECODE=1
         
     | 
| 6 | 
         
            +
            ENV PYTHONUNBUFFERED=1
         
     | 
| 7 | 
         
            +
             
     | 
| 8 | 
         
            +
            # Install dependencies
         
     | 
| 9 | 
         
            +
            WORKDIR /app
         
     | 
| 10 | 
         
            +
            COPY requirements.txt /app/
         
     | 
| 11 | 
         
            +
            RUN pip install --no-cache-dir -r requirements.txt
         
     | 
| 12 | 
         
            +
             
     | 
| 13 | 
         
            +
            # Copy app files
         
     | 
| 14 | 
         
            +
            COPY . /app
         
     | 
| 15 | 
         
            +
             
     | 
| 16 | 
         
            +
            # Expose the port Flask will run on
         
     | 
| 17 | 
         
            +
            EXPOSE 7860
         
     | 
| 18 | 
         
            +
             
     | 
| 19 | 
         
            +
            # Run the Flask app
         
     | 
| 20 | 
         
            +
            CMD ["python", "app.py"]
         
     | 
    	
        app.py
    ADDED
    
    | 
         @@ -0,0 +1,23 @@ 
     | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
| 
         | 
|
| 1 | 
         
            +
            from flask import Flask, request, jsonify, render_template
         
     | 
| 2 | 
         
            +
             
     | 
| 3 | 
         
            +
            app = Flask(__name__)
         
     | 
| 4 | 
         
            +
             
     | 
| 5 | 
         
            +
            # Route for the home page
         
     | 
| 6 | 
         
            +
            @app.route('/')
         
     | 
| 7 | 
         
            +
            def index():
         
     | 
| 8 | 
         
            +
                return render_template('index.html')
         
     | 
| 9 | 
         
            +
             
     | 
| 10 | 
         
            +
            # Prediction endpoint (mock prediction for now)
         
     | 
| 11 | 
         
            +
            @app.route('/predict', methods=['POST'])
         
     | 
| 12 | 
         
            +
            def predict():
         
     | 
| 13 | 
         
            +
                data = request.json
         
     | 
| 14 | 
         
            +
                activities = data.get('activities')
         
     | 
| 15 | 
         
            +
                
         
     | 
| 16 | 
         
            +
                # Placeholder logic for prediction (replace with your ML model)
         
     | 
| 17 | 
         
            +
                if activities:
         
     | 
| 18 | 
         
            +
                    predicted_score = sum(activities) / len(activities)  # Example logic
         
     | 
| 19 | 
         
            +
                    return jsonify({'predicted_score': predicted_score})
         
     | 
| 20 | 
         
            +
                return jsonify({'error': 'No activities provided'}), 400
         
     | 
| 21 | 
         
            +
             
     | 
| 22 | 
         
            +
            if __name__ == '__main__':
         
     | 
| 23 | 
         
            +
                app.run(host='0.0.0.0', port=7860)
         
     | 
    	
        templates/index.html
    ADDED
    
    | 
         @@ -0,0 +1,12 @@ 
     | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
| 
         | 
|
| 1 | 
         
            +
            <!DOCTYPE html>
         
     | 
| 2 | 
         
            +
            <html lang="en">
         
     | 
| 3 | 
         
            +
            <head>
         
     | 
| 4 | 
         
            +
                <meta charset="UTF-8">
         
     | 
| 5 | 
         
            +
                <meta name="viewport" content="width=device-width, initial-scale=1.0">
         
     | 
| 6 | 
         
            +
                <title>Student Score Predictor</title>
         
     | 
| 7 | 
         
            +
            </head>
         
     | 
| 8 | 
         
            +
            <body>
         
     | 
| 9 | 
         
            +
                <h1>Welcome to the Student Score Predictor</h1>
         
     | 
| 10 | 
         
            +
                <p>Submit your activities scores via POST request to /predict to get the final score prediction.</p>
         
     | 
| 11 | 
         
            +
            </body>
         
     | 
| 12 | 
         
            +
            </html>
         
     |