I know the title is a bit off, but what I'm asking is if it is possible to have a python script on my website that can detect if my Android phone is connected to the computer Im using to view the page. I don't know if this is possible since I think python is server-side, but maybe this is possible to do with JavaScript? I'm fairl开发者_运维知识库y new to programming so I may not be as smart as you guys out there but if someone could just lead me in the right direction I would be grateful.
What you're looking for is not TOTALLY ABSOLUTELY impossible, but you may need some help from the computer you connect the device to, from the browser you're visiting your site with or from the device itself. Some possible options:
have a program running on your computer which checks if the device is connected and pinging a certain URL on your website if it is.
write a browser plugin which checks if the device is connected and exposing the information via some JS API - the JS code on your site will be able to use it.
have a program running on your device which pings your site each time the device is connected to a computer.
Admittedly, all the solutions are from the "tricky" category :)
What you're looking for isn't possible and should not be possible for security concerns. Do you want someone knowing what devices you have connected to your computer? You're essentially wanting a device sniffer but a website would not be capable of accessing the client's machine in this manner to access the desired information.
精彩评论