Cannot access endpoint from outside railway
giannsaicpibot99
PROOP

a year 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

a year ago

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


giannsaicpibot99
PROOP

a year 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

a year ago

and this is how I run the fastapi from within python

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


giannsaicpibot99
PROOP

a year 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

a year ago


giannsaicpibot99
PROOP

a year ago

This is also how my function looks like:

class ChatID(BaseModel):
chat_id: int

@app.post("/updatefound") async def updatefound(chatdata: ChatID): try: groupchatid = chatdata.chatid print(f"Received groupchatid: {groupchatid} for updatefound")
return {"message": "Success"}
except Exception as e:
print("ERROR IN ENDPOINT: ", e + " " + str(traceback.print_exc()))
return {"message": "Error"}


giannsaicpibot99
PROOP

a year ago

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


brody
EMPLOYEE

a year ago

you need to use https without a port


Loading...