I have running a python web.py server as my backend.
But when I try a GET request from a Flutter it gives me XMLHttpRequest error, but when I execute my function just as Dart it works. Just accessing my GET request via a chrome also works.
Flutter:
final String uri = "192.168.1.154:5002";
var response = await http.get(
Uri.http(
uri,
"/api/getAllSettings",
{}
),
).timeout(Duration(seconds: 10));
Python:
urls = (
'/api/getInverterStatus', 'getInverterStatus',
'/api/getSwitchStatus', 'getSwitchStatus',
'/api/getAllSwitchesStatus', 'getAllSwitchesStatus',
'/api/getAllSettings', 'getAllSettings',
'/api/saveSettings', 'saveSettings'
)
class getAllSettings:
# eg request http://192.168.1.154:5002/api/getAllSettings
def GET(self):
try:
sendData = []
allSettings = db.getAllRows(db.SwitchSetting.table_name)
for setting in allSettings:
sendData.append(setting.toMap())
except:
sendData = "N/A"
return sendData