I want to create a REST service, So I tried and here's my snippet
from bottle import route, run
#compute graph_list (python object of type list)
if __name__ == "__main__":
run(host='0.0.0.0', port=8881, server='cherrypy', debug=True)
Error: 500 Internal Server Error
Sorry, the requested URL 'http://localhost:8881/plot_graph' caused an error:
Unsupported response type: <type 'int'>
Bottle v0.12.9 server starting up (using CherryPyServer())...
Listening on http://0.0.0.0:8881/
Hit Ctrl-C to quit.
/Users/guru/python_projects/implement_LDA/lda/lib/python2.7/site-packages/bottle.py:2777: ImportWarning: Not importing directory '/Users/guru/python_projects/implement_LDA/lda/cherrypy': missing __init__.py
from cherrypy import wsgiserver
graph_list needs to contain strings, however, it looks like your list contains integers. You could convert these integers to strings with this:
return (str(i) for i in graph_list)
But note that the elements of the list are joined together which might not be what you want.
For the warning problem, it would appear that you have a directory named
cherrypy in the same directory as your main python script. Rename/remove that directory and bottle will import CherryPy from your site-packages directory. Or you could simply remove
server='cherrypy' from the call to
run() to use the default wsgiref server.