Forums

Chatbot runs in bash but not in a web page

I'm working with one of the chatbots from https://parl.ai/docs/index.html and have just managed to converse with my bot, initiating it in bash mode in my virtualenv at PythonAnywhere. Yay!

Now I'd like to move the whole interaction with the bot to a web page.

For this according to ParlAI docs, I need to have a chat server up and running and a client python script to run on the same machine and communicate thru a port. I have successfully created these two locally on my laptop and the client.py creates the interaction page at https://localhost:8080.

The name client.py is confusing as it is a client of the chat server, but it is also the web server for the interaction.

Once on that locally created and served page - the magic is on - a chatbot on a web page. And it can serve many pages simultaneously at localhost:8080.

At PythonAnywhere, I managed to create the chat server on port 8080, but once I tried to run the client, it mentioned that ports 8080 (or 80, 443) - connection refused.

First, I need a chat server to be able to talk with a client script via one of the ports on the same machine - is it possible at PA? How? Do I need to run everything within a web app or wsgi script (instead of bash) ?

In order to have a chat server and client at PythonAnywhere - I need some info:

  1. Host - is this the address of a web page that was created in Flask, Web2Py, etc? Or is it just the raw wsgi page - if I pick the manual configuration of the web app ?

  2. Port - for the chat server and client.py script to use ? (NOT the port to communicate with the world)

  3. Where is the web page that the client app creates dynamically ? (used to be localhost:8080 on my laptop). is it the address of the web app ?

Here are the details for running a ParlAI chatbot https://parl.ai/docs/tutorial_chat_service.html#browser

Many thanks for your help

hi, you wouldn't be able to run just any client server on any port on PythonAnywhere. in fact, to make a web app that external people can access from an external url-- that requires the code you are trying to be run to be in a uWSGI application.

re: your questions-

  1. the host is the domain name for your webapp
  2. you don't have any control over any of the ports-- both external and internal. ie. even internally, your code may be running on different servers, and also ports may arbitrarily already be used
  3. after you setup a webapp, it is just that url (eg: zombit.pythonanywhere.com instead of localhost:8080)