Add global _apiAddress
var + reformat
This commit is contained in:
parent
e163d25776
commit
b3724c49f4
@ -9,8 +9,10 @@ import Foundation
|
||||
import Alamofire
|
||||
import SwiftUI
|
||||
|
||||
private let _apiAddress_ = "http://127.0.0.1:5000"
|
||||
|
||||
let evaluators:[String:ServerTrustEvaluating]=[
|
||||
"http://192.168.5.129:8080":DisabledTrustEvaluator()
|
||||
_apiAddress_:DisabledTrustEvaluator()
|
||||
]
|
||||
let manager=ServerTrustManager(evaluators: evaluators)
|
||||
let session=Session.init(serverTrustManager:manager)
|
||||
@ -18,7 +20,8 @@ let session=Session.init(serverTrustManager:manager)
|
||||
class Api {
|
||||
|
||||
func getResponse(completion: @escaping(Bool?) -> Void) {
|
||||
session.request("http://192.168.5.129:8080/test",method:.get, encoding: JSONEncoding.default).response { response in
|
||||
let endpointAddress = _apiAddress_ + "/test"
|
||||
session.request(endpointAddress, method:.get, encoding: JSONEncoding.default).response { response in
|
||||
switch response.result {
|
||||
case.success:
|
||||
if response.response?.statusCode == 200 {
|
||||
@ -40,9 +43,10 @@ class Api {
|
||||
}
|
||||
|
||||
func getImageResponse(image: String, completion: @escaping(Bool?) -> Void) {
|
||||
let endpointAddress = _apiAddress_ + "/detectLicense"
|
||||
let parameters = ["imageFile": image] as [String : Any]
|
||||
|
||||
session.request("http://192.168.5.129:8080/detectLicense", method: .post, parameters: parameters as Parameters, encoding: JSONEncoding.default, headers: nil)
|
||||
session.request(endpointAddress, method: .post, parameters: parameters as Parameters, encoding: JSONEncoding.default, headers: nil)
|
||||
.response { response in
|
||||
switch response.result {
|
||||
case.success:
|
||||
@ -89,9 +93,10 @@ class Api {
|
||||
}
|
||||
|
||||
func getPlatsNumberResponse(image: String, completion: @escaping(Bool?) -> Void) {
|
||||
let endpointAddress = _apiAddress_ + "/getPlatesNumber"
|
||||
let parameters = ["imageFile": image] as [String : Any]
|
||||
|
||||
session.request("http://192.168.5.129:8080/getPlatesNumber", method: .post, parameters: parameters as Parameters, encoding: JSONEncoding.default, headers: nil)
|
||||
session.request(endpointAddress, method: .post, parameters: parameters as Parameters, encoding: JSONEncoding.default, headers: nil)
|
||||
.response { response in
|
||||
switch response.result {
|
||||
case.success:
|
||||
|
Loading…
Reference in New Issue
Block a user