Most of the backend stuff is in PHP which handle JSON request and response flow of data from Android app to backend.
I'd like to start writing Python code to handle the extra features I'm going to add in my app. How can I do that? Do I need to install Django or something like it in the backend? Our webhost does show "Python support". I'm guessing just a couple of Python classes and some helper library files would suffice.
But here's where I'm conceptually stuck:
In Android, on the app, in the user's side, suppose I send all my queries to backend with this function:
//Pseudo code on Android app
getServerResponse()
{
url = " ??? ";
jsondata = {somedata[a:b]};
response = sendData_andGetResponse(jsondata); // suppose this function sens json data and expects a server response.
showResults(response);
//Pseudo code on backend - BackendProcessing.py
def processRequest():
# some processing done here
response = "some_processed_data"
return response
My problem is, what and how do I integrate the backend Python code and the client side Android app code to communicate with each other. What should the URL be in my Android code to pass data from user to backend? How do I link them?
Do I need to specially setup some third party Python API to handle calls from the Android app at the backend? Or can I just do it with simple Python functions and classes with HTTP request and responses coming in for a particular URI?
You can include URL of the backend server in the android code. Define a variable for the URL of your backend server and use Httppost method for communication between backend and frontend. Details here http://developer.android.com/reference/org/apache/http/client/methods/HttpPost.html
You can do it with simple Python functions and classes with HTTP request and responses coming in for a particular URI. A third party Python API is not necessary.
You can also use Python based web frameworks like Django for the backend.