These are chat archives for cherrypy/cherrypy

6th
Jun 2017
Mayur Patil
@mayurpatil1211
Jun 06 2017 13:05
Hi everyone,
CherryPy is very much new for me i have written some code to scrape website and display the table but failed to render values direct from app.py... can anyone help me. here is project link-> https://github.com/mayurpatil1211/task.git
Jason R. Coombs
@jaraco
Jun 06 2017 13:43
@mayurpatil1211: When you say it fails to render values, do you mean that requesting / works, but requesting /displayData does not? What error do you get? Does the data get added to the database?
Mayur Patil
@mayurpatil1211
Jun 06 2017 18:18
@jaraco: yeah, i mean i want to render the json values like we render in flask render_template('index.html', data = data). Is there any option like this in CherryPy
Mayur Patil
@mayurpatil1211
Jun 06 2017 18:23
@jaraco: now i have to run the cherrypy server, and then have to open html file separately with right click.
Jason R. Coombs
@jaraco
Jun 06 2017 18:43
@mayurpatil1211 CherryPy doesn’t include nor recommend a template rendering mechanism, but is designed to allow any template library to be used.
So if you want Jinja style templates, as used by Flask and Django (IIRC), include Jinja in your installation and follow its instructions for rendering templates.
I personally love Genshi, because it uses XML (and XHTML) for clean, single-syntax templates.
But I admit, Genshi is something of an esoteric solution for most tastes.
Mayur Patil
@mayurpatil1211
Jun 06 2017 19:02
@jaraco ya i followed that but i am not getting how to pass JSON to the front-end, where i am using angular. Can you give me live example that you prepared?
@jaraco and thanks for the help :)
i am using websockets to display the JSON value on front-end, I hope you gone through my code, but while hosting that app on heroku, i am not getting how to do that. :(
Jason R. Coombs
@jaraco
Jun 06 2017 20:27
I’m sorry, but I won’t be able to help troubleshoot your application. Here’s what I recommend - simplify your application to a simple HTTP site running locally and then look at using the json tool to return the JSON (or simply set the Content-Type header and return the dumped JSON as you’re doing).