Forums

Using PythonAnywhere to host a Discord bot and websocket server

Hi, I am currently making a Flask web panel for a Discord bot, and I was wondering if it would be possible to also use PythonAnywhere to host the Discord bot and the localhost websocket server all on one PythonAnywhere server.

The Flask web panel would communicate with the Discord bot via IPC / websockets using this library. To do this, the Discord bot would host a websocket server (on localhost, port 20000), so that it could receive websocket requests from the Flask web panel for data (e.g., get information about a guild/server). This is the specific Python code that hosts the server.

I was wondering a couple of things.

  1. Would this even be possible with Python anywhere? Since I read that PythonAnywhere doesn't support websocket servers, but this would just be on localhost for inter-process communication between the web panel and bot.
  2. Could I simply host the Discord bot on a console instance and upgrade my package to handle the bot workload? Because the bot could potentially receive thousands of requests per second, and I wouldn't want it to noticeably hinder the performance of the web server.

Thank you, any advice would be appreciated.

You cannot create a websocket server on PythonAnywhere and you cannot host something on a console server that can be accessed from a different server.

Can a free account on PythonAnywhere accommodate socket connections? I'm exploring the features available and would like to confirm the capabilities of the free tier in this regard.

You cannot create a websocket server on PythonAnywhere