Reputation: 1088
On client side , following android code would make the call to the local server :
String link = "http://localhost:8080/test/cgi-bin/test.py";
URL url = null;
try {
url = new URL(link);
HttpURLConnection client = (HttpURLConnection) url.openConnection();
JSONObject jo = new JSONObject();
jo.put("desc","xyz");
String data2 = jo.toString();
client.setRequestMethod("Post");
// client.setRequestProperty("key","value");
client.setDoOutput(true);
OutputStreamWriter outputPost = new OutputStreamWriter(client.getOutputStream());
outputPost.write(data2);
outputPost.flush();
outputPost.close();
Earlier I was using servlets to interact with DB as the code below : Using HttpServlet class , i could get the request and its parameters :
public class ServletXYZ extends HttpServlet {
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
String method = request.getParameter("method");
Is there any way in python which allows me to do the same (getting parameter values from request) ?
Thanks.
Upvotes: 0
Views: 10744