I made a simple server using python flask in mac. Please find below the code.
from flask import Flask
app = Flask(__name__)
@app.route('/', methods=['GET', 'POST'])
def hello():
print("request received")
return "Hello world!"
if __name__ == "__main__":
app.run(debug=True)
I run it using python3 main.py
command.
While calling above API on url http://localhost:5000/
from Postman using GET / POST method, it always returns http 403 error.
Python version : 3.8.9
OS : Mac OS 12.4
Flask : 2.1.2
CodePudding user response:
Mac OSX Monterey (12.x) currently uses ports 5000 and 7000 for its Control centre hence the issue.
Try running your app from port other than 5000
and 7000
use this:
if __name__ == "__main__":
app.run(port=8000, debug=True)
You can also turn off AirPlay Receiver
in the Sharing
via System Preference.
Related discussion here: https://developer.apple.com/forums/thread/682332