Spaces:
Sleeping
Sleeping
Upload folder using huggingface_hub
Browse files- Dockerfile +1 -7
- app.py +4 -4
- requirements.txt +1 -0
Dockerfile
CHANGED
|
@@ -1,17 +1,11 @@
|
|
| 1 |
-
# Use an official lightweight Python image
|
| 2 |
FROM python:3.10-slim
|
| 3 |
|
| 4 |
-
# Set working directory
|
| 5 |
WORKDIR /app
|
| 6 |
|
| 7 |
-
# Copy all files into the container
|
| 8 |
COPY . .
|
| 9 |
|
| 10 |
-
# Install dependencies
|
| 11 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 12 |
|
| 13 |
-
# Expose the port Streamlit/Flask will run on
|
| 14 |
EXPOSE 7860
|
| 15 |
|
| 16 |
-
|
| 17 |
-
CMD ["python", "app.py"]
|
|
|
|
|
|
|
| 1 |
FROM python:3.10-slim
|
| 2 |
|
|
|
|
| 3 |
WORKDIR /app
|
| 4 |
|
|
|
|
| 5 |
COPY . .
|
| 6 |
|
|
|
|
| 7 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 8 |
|
|
|
|
| 9 |
EXPOSE 7860
|
| 10 |
|
| 11 |
+
CMD ["gunicorn", "-w", "4", "-b", "0.0.0.0:7860", "app:superkart_api"]
|
|
|
app.py
CHANGED
|
@@ -4,17 +4,17 @@ import numpy as np
|
|
| 4 |
import pandas as pd
|
| 5 |
from flask import Flask, request, jsonify
|
| 6 |
|
| 7 |
-
|
| 8 |
|
| 9 |
print("π Loading model...")
|
| 10 |
model = joblib.load("superkart_model.joblib")
|
| 11 |
print("β
Model loaded.")
|
| 12 |
|
| 13 |
-
@
|
| 14 |
def index():
|
| 15 |
return "β
SuperKart API is live."
|
| 16 |
|
| 17 |
-
@
|
| 18 |
def predict():
|
| 19 |
try:
|
| 20 |
data = request.get_json(force=True)
|
|
@@ -45,4 +45,4 @@ def predict():
|
|
| 45 |
|
| 46 |
if __name__ == "__main__":
|
| 47 |
print("π Starting Flask server...")
|
| 48 |
-
|
|
|
|
| 4 |
import pandas as pd
|
| 5 |
from flask import Flask, request, jsonify
|
| 6 |
|
| 7 |
+
superkart_api = Flask(__name__)
|
| 8 |
|
| 9 |
print("π Loading model...")
|
| 10 |
model = joblib.load("superkart_model.joblib")
|
| 11 |
print("β
Model loaded.")
|
| 12 |
|
| 13 |
+
@superkart_api.route("/")
|
| 14 |
def index():
|
| 15 |
return "β
SuperKart API is live."
|
| 16 |
|
| 17 |
+
@superkart_api.route("/predict", methods=["POST"])
|
| 18 |
def predict():
|
| 19 |
try:
|
| 20 |
data = request.get_json(force=True)
|
|
|
|
| 45 |
|
| 46 |
if __name__ == "__main__":
|
| 47 |
print("π Starting Flask server...")
|
| 48 |
+
superkart_api.run(host="0.0.0.0", port=7860)
|
requirements.txt
CHANGED
|
@@ -1,4 +1,5 @@
|
|
| 1 |
flask
|
|
|
|
| 2 |
joblib
|
| 3 |
numpy
|
| 4 |
pandas
|
|
|
|
| 1 |
flask
|
| 2 |
+
gunicorn
|
| 3 |
joblib
|
| 4 |
numpy
|
| 5 |
pandas
|