问题
I have written a web service locally using python flask framework which runs on localhost:5000
, I run this web service successfully from my computers browser by writing http://localhost:5000/toi/something
Now I am trying to call same service from the browser of my android device by connecting it with the machine. I am doing this for the first time so I am not sure whether it works this way or I am doing something wrong but it does not show me the output on my android device. Once this is done I will be calling the web service programatically in my android application.
Thank You
回答1:
I don't think that will work, if you´ve got the phone connected to the same Wifi network than your computer you should access it this way:
http://ipofyourcomputer:5000/toi/something/
Once this works out you can try it with some of the libraries available on Android like:
OkHttp - https://github.com/square/okhttp
android-async-http - http://loopj.com/android-async-http/
Volley - https://android.googlesource.com/platform/frameworks/volley
Or if you're building a REST service you can use:
Retrofit - http://square.github.io/retrofit/
Hope it helps.
回答2:
My problem solved by turning off windows firewall.
来源:https://stackoverflow.com/questions/21879151/calling-web-service-from-android-device