在Web应用程序中设置应用程序根

问题描述 投票:0回答:1

如何为在瓶中开发的应用程序设置应用程序根目录。

我已经写了这样的瓶子应用程序

app = Bottle()

@route(path = '/GetMain')
def get_main_page():
  return static_file(...)

app.run(host=socket.getfqdn(), port=8080)

通过以上代码,我可以像http://xxxx.com:8080/GetMain一样检索我的页面。但是,如果我希望我的代码部署在http://xxxx.com:8080/dashboard/GetMain下,我如何更改我的应用程序根目录。我不想改变我的所有URL和reative路径

python-2.7 bottle
1个回答
0
投票

您可以通过指定前缀来安装它。

这是一个工作示例代码段。

import socket
from bottle import route, default_app


@route(path = '/GetMain')
def get_main_page():
  # Commenting out the below line for testing this snippet.
  # return static_file(...)
  return "Hello World"


if __name__ == '__main__':
    app = default_app()
    app.mount('/dashboard', app)
    app.run(host=socket.getfqdn(), port=8080)

请注意,我已经使用python 3.5进行了测试

© www.soinside.com 2019 - 2024. All rights reserved.