Re: Static URL in cherrypy

Kearney Taaffe <[email protected]>
Newsgroups gmane.comp.python.cherrypy
Message-ID <[email protected]>
Hopefully this helps you.

Here's a simple site I created just to serve static web-content. 

*DIRECTORY STRUCTURE*
public/
   css/
       style.css
   js/
   views/
       index.html
server.py

and here's the code I have in my *server.py* file

import os
import cherrypy

class Root(object):
    pass       

if __name__ == '__main__':
    root = os.path.dirname(os.path.abspath(__file__))  # this file's 
directory
    print root
        
    cherrypy.config.update( {
        'server.socket_host': '0.0.0.0',
        'server.socket_port': 8080,
    } )
    
    conf = {
        '/': {
            'tools.staticdir.on': True,
            'tools.staticdir.dir': root + '/public',
            'tools.staticdir.index': '/public/views/index.html'
        }
    }
    cherrypy.quickstart(Root(), '/', conf)




On Tuesday, December 8, 2015 at 7:06:40 AM UTC-6, SuperTwister wrote:
>
> My web site works with a cherrypy server, and HTML/JS client. I want that 
> that my website will have a static link, so no matter which page will be 
> visited, the URL on the browser will be stay the same.
>
> Currently the link is:
>
> /static/index.html
>
> I want that the link will be:
>
> /home
>
> Here is the website configuration:
>
> class Root(object):
>     def __init__(self, target):
>         self.target_server = target
>
>  cherrypy.quickstart(webapp, '/', conf)
>
> I have tried to change cherrypy.quickstart(webapp, '/', conf) to cherrypy.quickstart(webapp, 
> '/home', conf), but it's just changed the link to /home/static/index.html.
>
> Any idea?
>
>

-- 
You received this message because you are subscribed to the Google Groups "cherrypy-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cherrypy-users+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/[email protected]
To post to this group, send email to cherrypy-users-/JYPxA39Uh5TLH3MbocFF+G/[email protected]
Visit this group at https://groups.google.com/group/cherrypy-users.
For more options, visit https://groups.google.com/d/optout.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.