Forums

How can I visit my service based on CherryPy?

Hi guys,

My application is based on CherryPy and its job is to serve json data service, which can be used in ajax request. This app works well in my local machine and I can easily visit the service, for example, if I open http://127.0.0.1:8787/query_download?params_str=10151 and the required json data will be returned. However, after I copy the app to the pythonanywhere and start the app, it seems that everything goes well, here is the server.conf for CherryPy and some output:

server.conf:

[global]
server.socket_port: 8787
log.error_file='./log/error.log'
log.access_file='./log/access.log'

output in the console:

10:07 ~ $ python class_webserver.py 
Wed May 27 10:08:35 2015: ./no_weekends_holidays_2015-03-23_2015-03-23.dict load finished.
[27/May/2015:10:08:35] ENGINE Listening for SIGHUP.
[27/May/2015:10:08:35] ENGINE Listening for SIGTERM.
[27/May/2015:10:08:35] ENGINE Listening for SIGUSR1.
[27/May/2015:10:08:35] ENGINE Bus STARTING
[27/May/2015:10:08:35] ENGINE Started monitor thread 'Autoreloader'.
[27/May/2015:10:08:35] ENGINE Started monitor thread '_TimeoutMonitor'.
[27/May/2015:10:08:35] ENGINE Serving on 127.0.0.1:8787
[27/May/2015:10:08:35] ENGINE Bus STARTED

Here comes the question: How can I visit the data interface as what I have done in my local machine? I have tried that http://theofeng.pythonanywhere.com:8787/query_download?params_str=10151 but it did not work, I also simulated the ajax request in Chrome as:

$.getJSON('http://127.0.0.1:8787/query_download?params_str=10151', function( data ) { console.log(data); });

but it showed me an error message 'GET http://127.0.0.1:8787/query_download?params_str=10151 net::ERR_CONNECTION_REFUSED'.

Any advice will be appreciated!!!

Hi theofeng,

Have you seen this? Basically instead of using the native server part of cherrypy, you should set it up to use our uWSGI server.

Conrad

Much gratitude! It works really well! Thanks a lot!