heroku python heroku port issue 1

heroku python heroku port issue

import os 
port = int(os.environ.get('PORT', 33507))  # add these lines in code
app.run(host=args.host, port=port, debug=True)  

heroku config:add PORT=33507   # run this command once you upadte the code in terminal

Here is what the above code is Doing:
1. We’re using the os module to get the value of the PORT environment variable.
2. If the PORT environment variable is not set, we’re setting the port to 33507.
3. We’re passing the port to the app.run() method.
4. We’re setting the host to the value of the –host command line argument.
5. We’re setting the debug flag to True.

Similar Posts