I have a python http server per https://realpython.com/python-http-server/#how-to-start-pythons-httpserver-in-the-command-line
It's working fine in pure dart:
import 'package:http/http.dart' as http;
main() async {
var url = Uri.http('192.168.0.140:8000', 'whatsit/create');
var response =
await http.post(url, body: {'name': 'doodle', 'color': 'blue'});
print('Response status: ${response.statusCode}');
print('Response body: ${response.body}');
}
so I make an identical function in my Flutter app and call it from a button:
getRequest() async {
var url = Uri.http('192.168.0.140:8000', 'whatsit/create');
var response =
await http.post(url, body: {'name': 'doodle', 'color': 'blue'});
print('Response status: ${response.statusCode}');
print('Response body: ${response.body}');
}
and it throws and XMLHttpRequest error.
I know I should probably be using https but I don't understand why it runs in pure dart but not flutter.