Spaces:
Runtime error
Runtime error
Add new files
Browse files- Dockerfile +20 -0
- app/main.py +11 -0
Dockerfile
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Use an official Python runtime as a parent image
|
| 2 |
+
FROM tiangolo/uvicorn-gunicorn-fastapi:python3.8
|
| 3 |
+
|
| 4 |
+
# Set the working directory in the container to /app
|
| 5 |
+
WORKDIR /app
|
| 6 |
+
|
| 7 |
+
# Copy the current directory contents into the container at /app
|
| 8 |
+
COPY . /app
|
| 9 |
+
|
| 10 |
+
# Install any needed packages specified in requirements.txt
|
| 11 |
+
RUN pip install --trusted-host pypi.python.org fastapi[all] uvicorn
|
| 12 |
+
|
| 13 |
+
# Make port 80 available to the world outside this container
|
| 14 |
+
EXPOSE 80
|
| 15 |
+
|
| 16 |
+
# Define environment variable for uvicorn to run on 0.0.0.0
|
| 17 |
+
ENV HOST 0.0.0.0
|
| 18 |
+
|
| 19 |
+
# Run the command to start uvicorn
|
| 20 |
+
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "80"]
|
app/main.py
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from fastapi import FastAPI, HTTPException, Body
|
| 2 |
+
|
| 3 |
+
app = FastAPI()
|
| 4 |
+
|
| 5 |
+
@app.post("/question/")
|
| 6 |
+
async def read_question(question: str = Body(..., embed=True)):
|
| 7 |
+
return {"Received Question": question}
|
| 8 |
+
|
| 9 |
+
@app.post("/opportunity/")
|
| 10 |
+
async def read_opportunity(opportunity: str = Body(..., embed=True)):
|
| 11 |
+
return {"Received Opportunity": opportunity}
|