Cannot access endpoint from outside railway
giannsaicpibot99
PROOP

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

giannsaicpibot99
PROOP

2 years ago

88650658-638b-4d47-8fab-a98e65abea9a


giannsaicpibot99
PROOP

2 years ago

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"]`


giannsaicpibot99
PROOP

2 years ago

and this is how I run the fastapi from within python

uvicorn.run(app, host="0.0.0.0", port=3000)


giannsaicpibot99
PROOP

2 years ago

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


giannsaicpibot99
PROOP

2 years ago


giannsaicpibot99
PROOP

2 years ago

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"}


giannsaicpibot99
PROOP

2 years ago

Ignore me I didnt had to put the port in the url and it worked


2 years ago

you need to use https without a port


Welcome!

Sign in to your Railway account to join the conversation.

Loading...