2 years ago
I am trying to create an endpoint in my service but I cant seem to access it from outside railway
8 Replies
This is how my docerfile looks like:
`FROM python:3.9-slim
ENV PYTHONUNBUFFERED=1
WORKDIR /app
RUN apt-get update && apt-get install -y
imagemagick
libgl1-mesa-glx
libglib2.0-0
libsm6
libxrender1
libxext6
&& apt-get clean
&& rm -rf /var/lib/apt/lists/*
COPY policy.xml /etc/ImageMagick-6/policy.xml
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
COPY . .
CMD ["hypercorn", "telegram-bot:app", "--bind", "0.0.0.0:3000"]`
and this is how I run the fastapi from within python
uvicorn.run(app, host="0.0.0.0", port=3000)
just realised I was using uvicorn inside the python script. Ive removed it completely and also added PORT to be 3000 in railway variables but I cant access the endpoint still
this is the address im trying to access http://buybotnotifications-production.up.railway.app:3000/update_found
This is also how my function looks like:
class ChatID(BaseModel):
chat_id: int
@app.post("/update_found")
async def update_found(chat_data: ChatID):
try:
group_chat_id = chat_data.chat_id
print(f"Received group_chat_id: {group_chat_id} for update_found")
return {"message": "Success"}
except Exception as e:
print("ERROR IN ENDPOINT: ", e + " " + str(traceback.print_exc()))
return {"message": "Error"}
2 years ago
you need to use https without a port