我已经用 Java 实现了一个 REST 服务:
@POST
@Path("/policyinjection")
@Produces(MediaType.APPLICATION_JSON)
public String policyInjection(String request) {
String queryresult = null;
String response = null;
if (request == null) {
logger.warning("empty request");
} else {
//call query() to query redisDB with the request
queryresult = query(request);
// call inject() to inject returned policy to floodlight
response = inject(queryresult);
}
return response;
}
但是我需要使用 Python 来实现客户端向上述服务发出 POST 请求。我是 python 新手,我想实现一个方法,这样做:
def callpolicyInjection():