@app.route() doubt

Why @app.route() is used? Can you give more clarity on this?

hey @Mohit2000 ,
Every url of an API is defined as a route.
Means , whenever we request on this route/url then it will return something or show something.
So , in flask , we define such url using app.route() ,
by default flask runs server on 127.0.0.1:5000 ( localhost ),
so if we do it like , app.route("/home") , then if we navigate to 127.0.0.1:5000/home , it will show the output of either returning a json or preview html file , whatever we implement in the code.

I hope this helps.

I am confused! Telegram server basically tells our server program that a message has been received by the bot and I think app.route() defines the route of our server. From where API comes into picture here, please explain.

hey @Mohit2000 ,
The thing i explained above telld you the way flask works.
Telegram bot provides a kind of a API which gets connected to the flask server and responds to our requests.
You can instantiate any route of your choice , but the working of telegram to attach a webhook works on a special route and method.
Telegram bot doesn’t just tell the server that there is a message , it is not called as so , its called a request . It can be anything , a reply , a status , etc. not just a message.

So, when send any message using telegram bot , the server receives our request , transfer it to telegram , gathers response and respond accordingly.
Telegram uses these different routes to gather some information needed to respond to our request.

I hope this helps.

why f is used while defining route f’/{TOKEN}’

hey @Mohit2000 ,
there are multiple methods in python to format a string.
this is one of such.
the same way we do string.format.
similarly we just add an f at starting and we then put the variable inside curly braces as shown above , to make it work.

Ports currently supported for webhook by flask are : 443,80,88,8443. So the default url on which flask server runs is of no use here?

no it is not as such.
You can use any port , until it is being in currently use by any other application.
and also use the same port to run ngrok server , so that it can listen to its requests.

Can you explain what is actually meant by a port?

Port is like a point where multiple things can connect and work together.
So , like here we run our flask on port 8443 and also asks ngrok to listen on the same port , so that we can get the reponses of our requests made by flask and telegram.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.

telegram.error.BadRequest: Bad webhook: failed to resolve host: name or service not known

this error is popping, don’t know what to do

hey @Vishal1072 ,
kindly create a new doubt in discussion forum and also share a screenshot of this error.
I t would be helpful for me to understand from that.

Thank You :slightly_smiling_face:

I have created the new topic but no one is replying there

hey @Vishal1072 ,
I can’t see any on discussion forum.
Can you please close that one and create one now , i will look into it.
Sorry for this trouble.

I have just now created another topic, have a look to it

its still not showing ,
share me its link

hey @Vishal1072 ,
its not a new doubt created . Its just got into reference to another , thats the reason no one its not showing.

can you please create a new one.