问题
I have a beginner PythonAnywhere account, which, the account comparison page notes, have "Access to External Internet Sites: Specific Sites via HTTP(S) Only."
So I know only certain hosts can be accessed through HTTP protocols, but are there restrictions on use of the socket
module? In particular, can I set up a Python server using socket
?
回答1:
PythonAnywhere dev here. Short answer: you can't run a socket server on PythonAnywhere, no.
Longer answer: the socket module is supported, and from paid accounts you can use it for outbound connections just like you could on your normal machine. On a free account, you could also create a socket connection to the proxy server that handles free accounts' Internet access, and then use the HTTP protocol to request a whitelisted site from it (though that would be hard work, and it would be easier to use requests
or something like that).
What you can't do on PythonAnywhere is run a socket server that can be accessed from outside our system.
回答2:
Nope. PythonAnywhere doesn't support the socket module.
来源:https://stackoverflow.com/questions/46018426/pythonanywhere-are-sockets-allowed