从瓶子模板中引用图像的方法是什么?

What is the way to reference an image from within a bottle template?

在瓶子模板文件中,引用静态文件的方法是什么?比如这个?

<body background='/static/img/digital.gif'>

为什么上面的相关文件加载图片失败? 我怎样才能正确引用它?如果我将其尝试为:

<body background="{{ static_file( 'digital.gif', root='./static/img' }}">

图像也无法渲染。

为什么 Bottle 没有使用 'static_file' 函数也无法渲染图像?

您应该向您的应用程序添加一个路由,以便在请求时 return 静态文件。然后使用html中的路径作为普通路径。

所以添加这个:

@app.route('/static/<filepath:path>')
def server_static(filepath):
    return static_file(filepath, root='/path/to/static')

然后访问:http://localhost:8080/static/file.txt 将 return '/path/to/static/file.txt'。

“/path/to/static”的子文件夹也可以访问。

我正在尝试弄清楚如何始终通过 ssh 将错误输出到浏览器而不是 logginf,并且 'tail -f error_log' ?

在开发实例中我们刚刚调试=True,现在在生产服务器中?这是我的配置:

DocumentRoot /home/nikos/public_html

<Directory /home/nikos/public_html>
    Require all granted
</Directory>


Alias /static /home/nikos/public_html/static

<Directory /home/nikos/public_html/static>
    Options +Indexes
</Directory>


WSGIPassAuthorization On

WSGIDaemonProcess clientele user=nikos group=nikos home=/home/nikos/public_html
WSGIScriptAlias /clientele /home/nikos/public_html/clientele.py process-group=clientele application-group=%{GLOBAL}

WSGIDaemonProcess downloads user=nikos group=nikos home=/home/nikos/public_html
WSGIScriptAlias /downloads /home/nikos/public_html/downloads.py process-group=downloads application-group=%{GLOBAL}

WSGIDaemonProcess www user=nikos group=nikos home=/home/nikos/public_html
WSGIScriptAliasMatch ^/(?!phpmyadmin) /home/nikos/public_html/www.py process-group=www application-group=%{GLOBAL}

我还想知道如何获取在身份验证提示中输入的 authuser 值,以便在输入时存储它。 request.auth.user' 不会 return 它也不会 request.auth.username'.