keiffster / program-y

Python 3.x based AIML 2.0 Chatbot interpreter, framework, related programs and knowledge files
https://keiffster.github.io/program-y/
Other
349 stars 137 forks source link

Programy on PythonAnywhere #283

Closed simonmacdonald closed 3 years ago

simonmacdonald commented 3 years ago

I'm a relative Python novice.

I've installed programy on PythonAnywhere and have been trying to run the ybot webchat client using WSGI, currently without success when trying to import APP using this in the WSGI.config.

from programy.clients.restful.flask.webchat.client import APP as application  # noqa

with the following error:

2021-02-02 11:33:22,799: Error running WSGI application
2021-02-02 11:33:22,801: ImportError: cannot import name 'APP' from 'programy.clients.restful.flask.webchat.client' 
(/home/quiraang/.virtualenvs/mickey/lib/python3.8/site-packages/programy/clients/restful/flask/webchat/client.py)
2021-02-02 11:33:22,802:   File "/var/www/quiraang_eu_pythonanywhere_com_wsgi.py", line 18, in <module>
2021-02-02 11:33:22,802:     from programy.clients.restful.flask.webchat.client import APP as application  # noqa

The support team advise that it is because APP is within the if statement in client.py and the code is never run:

if __name__ == '__main__':
REST_CLIENT = None

outputLog(None, "Initiating Flask REST Service...")
APP = Flask(__name__)

@APP.route('/api/rest/v1.0/ask', methods=['GET', 'POST'])
def ask_v1_0():
    response_data, status = REST_CLIENT.process_request(request, version=1.0)
    return REST_CLIENT.create_response(response_data, status, version=1.0)

@APP.route('/api/rest/v2.0/ask', methods=['GET', 'POST'])
def ask_v2_0():
    response_data, status = REST_CLIENT.process_request(request, version=2.0)
    return REST_CLIENT.create_response(response_data, status, version=2.0)

outputLog(None, "Loading, please wait...")
REST_CLIENT = FlaskRestBotClient("flask")
REST_CLIENT.run(APP)

is there any advice you can give about how I might tackle this problem or, if as quite likely, I'm doing it incorrectly many thanks

simonmacdonald commented 3 years ago

No response so I might as well close this