Skip to content

Commit

Permalink
Build new API url with various of settings
Browse files Browse the repository at this point in the history
  • Loading branch information
monolidth committed Jan 11, 2021
1 parent 69d118f commit 6830598
Showing 1 changed file with 23 additions and 6 deletions.
29 changes: 23 additions & 6 deletions lib/network/network_client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,19 @@ class NetworkClient {
HttpOverrides.global = new SelfSignedHttpAgent();
}

static String buildUrl(final ip, final token) {
static String buildUrl(final ip, final token, final legacyParser, final gaussian, final grayscale, final rotate) {
if (token == null || token == "")
return _protocol + ip + ":" + _port + _path;
return _protocol + ip + ":" + _port + _path + _access_token + token;
return _protocol + ip + ":" + _port + _path + "&legacy_parser=" + getValue(legacyParser) + "&grayscale_image=" + getValue(grayscale) + "&gaussian_blur=" + getValue(gaussian) + "&rotate=" + getValue(rotate);
return _protocol + ip + ":" + _port + _path + _access_token + token + "&legacy_parser=" + getValue(legacyParser) + "&grayscale_image=" + getValue(grayscale) + "&gaussian_blur=" + getValue(gaussian) + "&rotate=" + getValue(rotate);
}

/// Convert boolean values to python boolean values
static String getValue(final bool val) {
if (val == null || val == false) {
return "False";
} else {
return "True";
}
}

static toNavigationBar(BuildContext context) {
Expand All @@ -63,8 +72,16 @@ class NetworkClient {
}

/// Send image via post request to the server and capture the response.
static sendImage(File imageFile, String ip, String token,
bool sendDebugOutput, BuildContext context,
static sendImage(
File imageFile,
String ip,
String token,
bool sendDebugOutput,
bool grayscale,
bool gaussian,
bool legacyParser,
bool rotate,
BuildContext context,
[GlobalKey<ScaffoldState> key]) async {
init();

Expand All @@ -86,7 +103,7 @@ class NetworkClient {
stream.cast();

var length = await imageFile.length();
var uri = Uri.parse(buildUrl(ip, token));
var uri = Uri.parse(buildUrl(ip, token, legacyParser, gaussian, grayscale, rotate));

log(uri.toString());

Expand Down

0 comments on commit 6830598

Please sign in to comment.