Its been a while since I’ve done any coding and trying to stand up a very simple API used for development
from flask import Flask, request, jsonify
from flask_cors import CORS
app = Flask(__name__)
CORS(app)
@app.route('/get_message', methods=['GET'])
def print_message():
print('this ran')
return 'this ran'
if __name__ == '__main__':
app.run(debug=True)
to test this api, I’m running this simple script
url = 'http://localhost:5000/get_message'
try:
response = requests.get(url)
response.raise_for_status()
print('Response from server:', response.text)
except requests.exceptions.RequestException as e:
print(f'Request failed: {e}')
but I keep getting this answer
Request failed: 403 Client Error: Forbidden for url: http://localhost:5000/get_message
CORS should solve for this? I’m struggling to figure out what I’m doing wrong