Google posted a solution for this kind of problem here.
The steps:
- Connect your Android device and your development machine with USB debugging enabled
- Open Chrome in your development machine, open new tab, right click in the new browser tab, click inspect
- Click the three dots icon on right top side , -> More Tools, Remote Devices.
- Look at bottom of the screen, make sure your device name is appeared on the list with Green colored dot.
- Look below at the settings part, check the Port forwarding mark
- Add rule. Example, if your python web server is running on your machine localhost:5000 and you want to access it from your device port 3333, you type
3333
on the left part, and typelocalhost:5000
, and click add rule. - Voila, now you can access your web server from your device. Try open new browser tab, and visit http://localhost:3333 from your device