Spaces:
Running
Running
Commit
·
d36eb3b
1
Parent(s):
76a06ee
no message
Browse files- Dockerfile +16 -0
- app/app.py +20 -0
- requirements.txt +3 -0
Dockerfile
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Read the doc: https://huggingface.co/docs/hub/spaces-sdks-docker
|
| 2 |
+
# you will also find guides on how best to write your Dockerfile
|
| 3 |
+
|
| 4 |
+
FROM python:3.9
|
| 5 |
+
|
| 6 |
+
RUN useradd -m -u 1000 user
|
| 7 |
+
USER user
|
| 8 |
+
ENV PATH="/home/user/.local/bin:$PATH"
|
| 9 |
+
|
| 10 |
+
WORKDIR /app
|
| 11 |
+
|
| 12 |
+
COPY --chown=user ./requirements.txt requirements.txt
|
| 13 |
+
RUN pip install --no-cache-dir --upgrade -r requirements.txt
|
| 14 |
+
|
| 15 |
+
COPY --chown=user . /app
|
| 16 |
+
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
|
app/app.py
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from flask import Flask, jsonify, request
|
| 2 |
+
|
| 3 |
+
app = Flask(__name__)
|
| 4 |
+
|
| 5 |
+
@app.route('/api/add', methods=['POST'])
|
| 6 |
+
def add_numbers():
|
| 7 |
+
data = request.json
|
| 8 |
+
result = data['a'] + data['b']
|
| 9 |
+
return jsonify({'result': result})
|
| 10 |
+
|
| 11 |
+
@app.route("/")
|
| 12 |
+
def home():
|
| 13 |
+
return "Hello, Flask! 이건 루트 경로입니다."
|
| 14 |
+
|
| 15 |
+
@app.route("/product")
|
| 16 |
+
def reponse_prod():
|
| 17 |
+
return jsonify({'result': "This is a product response!"})
|
| 18 |
+
|
| 19 |
+
if __name__ == '__main__':
|
| 20 |
+
app.run(debug=True)
|
requirements.txt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
uvicorn[standard]
|
| 2 |
+
flask
|
| 3 |
+
flask-cors
|