I tried again and it's still the same problem.
Flask server :
from flask import Flask, request, Response
from flask_cors import CORS, cross_origin
app = Flask(__name__)
cors = CORS(app)
@app.route("/process", methods=['GET', 'POST']) # used for airtable webhooks -> programming notifications
def process():
print(request)
json_string = "webhook received"
resp = Response(json_string)
resp.headers['Access-Control-Allow-Origin'] = '*'
return resp
if __name__ == '__main__':
app.run(host='192.168.1.12', port=8050, debug=True)Airtable script :
let url = 'https://192.168.1.12:8050/process';
const options = {
method : "GET",
headers: {
"Content-Type": "application/json",
"Access-Control-Allow-Origin" : "https://airtable.com"
},
};
let res = await fetch(url, options);
console.log(res);And no it has never worked from Airtable to Flask. However, using 'https://192.168.1.12:8050/process' in a browser works perfectly. The response is returned and displayed onto the web page.
Right, but that's because 192.168... is on your local network. When you run code from Airtable, you are using their servers. You cannot access a 192.168.. (ie local address) from an Airtable script. You will need Flask running on a public server that you can access. The original code you showed had a public IP address - that's what you need to be using. Which was why I was saying to be VERY, VERY careful when it comes to security and SSL policies. You NEVER want to expose any production servers - especially ones containing important (non-dummy) data - without having a very clear business case.
If you need to access Flask via your local IP address, then one option would be to write a little javascript app on your network that gets the Airtable info you need via Airtable's API and then forwards it along to Flash - and vice-versa. But this is not a clean solution, nor does it let you tie into automation hooks.
If the issues are CORS related, then you may not be able to use automation's fetch method. In which case, you'll want to consider Airtable scripting (outside of an automation) where you can use remoteFetchAsync.
If you want to elaborate a bit more on your specific use-case, I might be able to suggest some other options.