Hello to those who see this,
I have a problem running two simple applications in Cherrypy where I want to:
- mount Root() to handle static data in the "/" endpoint
- mount NodeApi() to handle Json Rest requests using the default dispatcher in the "/api" endpoint
The code is as follows:
===============================================
class Root(object):
pass
class NodeApi(object):
#some implemented functions accessible via @cherrypy.expose
================================================
ROOT_CONF = {
'/': {
'tools.sessions.on': True,
'tools.staticdir.root': ".../project/static" ,
'tools.staticdir.index': ".../project/static/index.html"
},
================================================
cherrypy.tree.mount(root=Root(), '/', config=ROOT_CONF)
cherrypy.tree.mount(root=NodeApi(), script_name='/api')
cherrypy.engine.start()
cherrypy.engine.block()
================================================
The cherrypy runner code (main.py) is placed in the ".../project" directory. The problem is that I can succesfully send request at http://...../api/somefunction and recieve desired result in json format, but I can't accesss my static data such as:
- http://......./ --> return .../project/static/index.html
- http://......./ --> return .../project/static/index.html
- http://...../assets/main.js --> return .../project/static/assets/main.js
- http://...../assets/icon.png --> return .../project/static/assets/icon.png
Unbelivebly some "/assets/..." would be resolved and some don't, also non of the static files within the "/project/statics" would be resolve at the root endpoint.
Overall, I think that I haven't choose the right method to implement this, any help on my issue or alternative solution is appriciated.
Tnx in advance,
reza