This commit is contained in:
Tibor Bossanyi 2023-03-29 15:27:51 +02:00
parent 953753196b
commit 9311a888bc
5 changed files with 23 additions and 26 deletions

6
.vscode/launch.json vendored
View File

@ -9,7 +9,11 @@
"program": "lib/example/lib/main.dart",
"args": [
"-d",
"chrome"
"chrome",
"--web-renderer",
"html",
"--web-port",
"48102",
]
}
]

View File

@ -1,5 +1,9 @@
Workout Test and Diet 4 You Common Util Functions
### Version 1.0.23
webapi CORS solution with the API
### Version 1.0.22
webapi CORS: only diet4you domains, plugins update

View File

@ -1,9 +1,12 @@
import 'package:flutter/material.dart';
import 'package:flutter_dotenv/flutter_dotenv.dart';
import 'package:workouttest_util/model/cache.dart';
import 'package:workouttest_util/service/customer_service.dart';
import 'package:workouttest_util/service/openai_service.dart';
void main() {
void main() async {
WidgetsFlutterBinding.ensureInitialized();
await dotenv.load(fileName: ".env");
runApp(const MyApp());
}
@ -14,8 +17,6 @@ class MyApp extends StatefulWidget {
State<MyApp> createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
String _response = "";
@ -25,14 +26,15 @@ class _MyAppState extends State<MyApp> {
}
void _fetchData() async {
var api = OpenAIApi();
String response = await api.getOpenAICompletion("Who wrote the song 'yellow submarine'?");
//var api = OpenAIApi();
//String response = await api.getOpenAICompletion("Who wrote the song 'yellow submarine'?");
await CustomerApi().getCustomer(72);
String response = "OK";
setState(() {
_response = response;
});
}
@override
Widget build(BuildContext context) {
Cache().setLocalBaseUrl();
@ -57,16 +59,12 @@ class _MyAppState extends State<MyApp> {
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
FloatingActionButton(
onPressed:() => {
_fetchData()
},
onPressed: () => {_fetchData()},
tooltip: 'Send question',
child: const Icon(Icons.ad_units),
),
],
)
],
),
),

View File

@ -27,7 +27,6 @@ class APIWebClient with Common, Logging {
final body = jsonEncode(<String, String>{'username': email, 'password': password});
var uri = Uri.parse(url);
var result = await http.post(uri, body: body, headers: {
"Access-Control-Allow-Origin": 'https://*.diet4you.eu, https://*.diet4you.hu, http://localhost',
"Content-Type": "application/json",
"Authorization": "1",
});
@ -65,10 +64,6 @@ class APIWebClient with Common, Logging {
}
var uri = Uri.parse(url);
var result = await http.post(uri, body: body, headers: {
"Access-Control-Allow-Origin": 'https://*.diet4you.eu, https://*.diet4you.hu, http://localhost',
"Access-Control-Allow-Headers": "Origin,Content-Type,Authorization,locale",
"Access-Control-Allow-Credentials": 'true', // Required for cookies, authorization headers with HTTPS
"Access-Control-Allow-Methods": "POST, GET, OPTIONS",
"Content-Type": "application/json",
"Authorization": 'Bearer $authToken',
});
@ -102,10 +97,6 @@ class APIWebClient with Common, Logging {
var uri = Uri.parse(url);
var result = await http.get(uri, headers: {
"Content-Type": "application/json",
"Access-Control-Allow-Origin": 'https://*.diet4you.eu, https://*.diet4you.hu, http://localhost',
"Access-Control-Allow-Headers": "Origin,Content-Type,Authorization,locale",
"Access-Control-Allow-Credentials": 'true', // Required for cookies, authorization headers with HTTPS
"Access-Control-Allow-Methods": "POST, GET, OPTIONS",
"Authorization": 'Bearer $authToken',
});

View File

@ -1,6 +1,6 @@
name: workouttest_util
description: Workout Test app and web functions.
version: 1.0.22
version: 1.0.23
environment:
sdk: ">=2.18.6 <3.0.0"