I have a website server based on python (cherrypy), and i need some help. I'm sorry in advance if this question is too basic. I don't have a vast of experience in this area so far.
My main page is on http://host:9090/home/static/index.html
.
I want to rewrite the address of above, and define the following address as the main page: http://host:9090/home/
. The code itself suppose to stay in the same place. I just want a shorter link so /home/static/index.html
will be available also in /home/
.
Is rewrite URL is what i need? If so, I've found the following link, but unfortunately i don't know how to implement it in my code: http://www.aminus.org/blogs/index.php/2005/10/27/url_rewriting_in_cherrypy_2_1?blog=2
cherrypy.config.update({
'server.socket_port': 9090,
'server.socket_host': '0.0.0.0'
})
conf = {
'/': {
'tools.sessions.on': True,
'tools.staticdir.root': os.path.abspath(os.getcwd())
},
'/static': {
'tools.staticdir.on': True,
'tools.staticdir.dir': './static/html'
},
'/js': {
'tools.staticdir.on': True,
'tools.staticdir.dir': './static/js'
},
'/css': {
'tools.staticdir.on': True,
'tools.staticdir.dir': './static/css'
},
'/img': {
'tools.staticdir.on': True,
'tools.staticdir.dir': './static/img'
},
'/fonts': {
'tools.staticdir.on': True,
'tools.staticdir.dir': './static/fonts'
}
}
class Root(object):
def __init__(self, target):
self.target_server = target
webapp = Root(args.target)
cherrypy.quickstart(webapp, '/home', conf)
Anyone can help?