yiyixin commited on
Commit
c4e5fab
1 Parent(s): 25a1940
Files changed (3) hide show
  1. Dockerfile +14 -8
  2. app.py +7 -7
  3. requirements.txt +1 -2
Dockerfile CHANGED
@@ -1,14 +1,20 @@
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
- WORKDIR /code
 
7
 
8
- COPY ./requirements.txt /code/requirements.txt
 
9
 
10
- RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
 
11
 
12
- COPY . .
 
13
 
14
- CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "7860"]
 
 
1
+ # Use an official Python runtime as a parent image
2
+ FROM python:3.9-slim
3
 
4
+ # Set the working directory to /app
5
+ WORKDIR /app
6
 
7
+ # Copy the requirements file into the container
8
+ COPY requirements.txt .
9
 
10
+ # Install any needed packages specified in requirements.txt
11
+ RUN pip install --no-cache-dir -r requirements.txt
12
 
13
+ # Copy the current directory contents into the container at /app
14
+ COPY . /app
15
 
16
+ # Expose port 7860 for the Flask app to listen on
17
+ EXPOSE 7860
18
 
19
+ # Run the command to start the Flask app
20
+ CMD ["python", "app.py"]
app.py CHANGED
@@ -1,10 +1,10 @@
1
- from fastapi import FastAPI
2
 
3
- app = FastAPI()
4
 
5
- @app.get("/")
6
- def read_root():
7
- return {"Hello": "World"}
8
 
9
- @app.get("/items/{item_id}")
10
- def read_item(item
 
1
+ from flask import Flask
2
 
3
+ app = Flask(__name__)
4
 
5
+ @app.route('/')
6
+ def hello_world():
7
+ return 'Hello, World!'
8
 
9
+ if __name__ == '__main__':
10
+ app.run(debug=True, host='0.0.0.0', port=7860)
requirements.txt CHANGED
@@ -1,2 +1 @@
1
- uvicorn==0.15.0
2
- fastapi==0.65.2
 
1
+ flask