Spaces:
Runtime error
Runtime error
Commit
·
11efcc9
1
Parent(s):
9c1ea0e
Add testing files
Browse files- Dockerfile +1 -1
- main.py +15 -0
- requirements.txt +4 -0
Dockerfile
CHANGED
|
@@ -8,4 +8,4 @@ RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
|
|
| 8 |
|
| 9 |
COPY . .
|
| 10 |
|
| 11 |
-
CMD ["uvicorn", "
|
|
|
|
| 8 |
|
| 9 |
COPY . .
|
| 10 |
|
| 11 |
+
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]
|
main.py
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from fastapi import FastAPI
|
| 2 |
+
import uvicorn
|
| 3 |
+
|
| 4 |
+
app = FastAPI()
|
| 5 |
+
|
| 6 |
+
@app.get("/")
|
| 7 |
+
def index():
|
| 8 |
+
return {"message": "Welcome to the index page!"}
|
| 9 |
+
|
| 10 |
+
@app.get("/hello")
|
| 11 |
+
def hello():
|
| 12 |
+
return {"message": "Hello, testing!"}
|
| 13 |
+
|
| 14 |
+
if __name__=='__main__':
|
| 15 |
+
uvicorn.run('main:app', reload=True)
|
requirements.txt
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# To ensure app dependencies are ported from your virtual environment/host machine into your container, run 'pip freeze > requirements.txt' in the terminal to overwrite this file
|
| 2 |
+
fastapi[all]==0.89.0
|
| 3 |
+
uvicorn[standard]==0.20.0
|
| 4 |
+
gunicorn==20.1.0
|