私はPython(cherrypy)に基づいたウェブサイトサーバーを持っています。私はいくつかの助けが必要です。この質問があまりにも基本的なものであれば、事前に申し訳なく思っています。私は今までこの分野での広大な経験を持っていません。スタティックURLチェリーピー
私のメインページはhttp://host:9090/home/static/index.html
です。 上記のアドレスを書き換えて、メインページとして次のアドレスを定義します:http://host:9090/home/
。コード自体は同じ場所にとどまることを想定しています。私はちょうど短いリンクがほしいので/home/static/index.html
は/home/
でも利用できるようになります。
書き換えURLが必要ですか?もしそうなら、私は次のリンクを発見しましたが、残念ながら、私は私のコードでそれを実装する方法がわからない: 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)
誰でも助けることができますか?
@qarma私は前述したように、私は、URLを書き換える必要があります。 – Omri