How to have one Flask app listen on two different ports?

flask, python

Solution

A server by default only listens to a single port. Wouldn't it make more sense, since the additional port requires additional functionality, to implement a front-end server on the second port that proxies the POST request locally? There are many well-documented ways to do this such as this one

Problem

Is it possible to have a single flask app with routes on two different ports? My Flask app needs to listen for webhooks and due to some security biz it can't receive foreign POST requests on the default port. Is it possible to do something like this? ``` @app.route('/hook/<sourcename>', methods=["POST"], port=5051) def handle_hook(sourcename): print 'asdf' ```

Original source

Related problems