I try to start using the python widget in Knowage application, but I have problem to set flask service on servers like WSGI or Apache. I follow the knowage documentation but there is no details how to launch such service. I want to mention I use the Windows 10 Pr.
Honestly I’m not much experience with python yet, so I need help I would like to get more details about such configuration, for example some sample files code how to deploy web service on those servers. The knowage documentation contains general information about it and sometimes confusing , for example it says to use the entry point ( The entry point for the application is Knowage-Python/pythonwebservice/knowage-python.py and the default port is 5000)
The python module for Knowage is available on GitHub and the structure of my project application below
|__ myapps
|__ pythonwebservice
|__ api
|__ logs
|__ __init__.py
|__ knowage-python.py
|__ wsgi_scripts
|__ my_wsgi.py
The file knowage-python.py contains
import sys
from app.services import create_app
from app.utilities import constants
import logging
LOG_FORMAT = "[%(filename)s:%(lineno)s - %(funcName)20s() ] %(message)s"
logging.basicConfig(format=LOG_FORMAT)
application = create_app()
if __name__ == '__main__':
if len(sys.argv) > 1:
port = int(sys.argv[0])
else:
port = 5000
open(constants.LOG_FILE, 'w+').close() #clean log file
original_stderr = sys.stderr
#sys.stderr = open(constants.LOG_FILE, 'a')
application.run(host='127.0.0.1', debug=False, port=port)
#application.run(host='0.0.0.0', debug=False, port=port, ssl_context=('cert.pem', 'key.pem'))
The my_wsgi.py
import sys
sys.path.insert(0, 'C:\\myapps')
from pythonwebservice import app as application
and the virtualhost for Apache myapp.conf
<VirtualHost *:5000>
ServerName localhost
WSGIScriptAlias / C:/myapps/wsgi_scripts/my_wsgi.py
<Directory C:/myapps/pythonwebservice>
Options +Indexes +Includes +FollowSymLinks +MultiViews
AllowOverride All
Require local
Require all granted
</Directory>
</VirtualHost>
It doesn't work.
I will apprecite any suggestions or examples