我使用此代码在Objective C中发出post请求
NSURL *baseURL = [NSURL URLWithString:@"http://192.168.1.147:5000/test"];
//static NSString *test = @"http://192.168.1.147:5000/test";
UIWindow *window = [[UIApplication sharedApplication] keyWindow];
UIView *topView = window.rootViewController.view;
AFHTTPSessionManager *manager = [[AFHTTPSessionManager alloc] initWithBaseURL:baseURL];
manager.requestSerializer = [AFJSONRequestSerializer serializer];
manager.responseSerializer = [AFJSONResponseSerializer serializer];
[manager POST:@"/" parameters:eventInfoObject success:^(NSURLSessionDataTask *task, id responseObject) {
....
我在Python中有两个使用Flask的函数:
@app.route("/", methods=['GET'])
def hello():
@app.route("/test", methods=['POST'])
def addEvent():
使用Charles查看发生了什么这是尝试使用Objective-C中的代码时得到的结果:
正如您所看到的,URL is not/test还表示405 METHOD not ALLOWED,这意味着它是Python中第一个只允许GET请求的方法。为什么不直接指向addEvent()函数?你知道吗
目前没有回答
相关问题 更多 >
编程相关推荐