- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在 python 中使用 Bottle 网络服务器。当我调试时,我想对伪html模板文件进行更改,然后重新加载页面以在浏览器中查看它。看来 Bottle 缓存了模板文件,我无法从新修改的模板中加载它们。
这是我的情况:
第一种方法
第二种方法
我强制浏览器再次请求该文件(不使用它自己的缓存),并且通过 python 调试器(PyCharm),我可以看到 Bottle Web 服务器至少假装执行以下操作它应该用模板文件做的所有事情。
最佳答案
来自http://bottlepy.org/docs/dev/stpl.html#bottle.SimpleTemplate
Just keep in mind that compiling and rendering templates are two different actions, even if the template() helper hides this fact. Templates are usually compiled only once and cached internally, but rendered many times with different keyword arguments.
但是http://bottlepy.org/docs/dev/tutorial.html#templates状态:
Caching
Templates are cached in memory after compilation. Modifications made to the template files will have no affect until you clear the template cache. Call
bottle.TEMPLATES.clear()
to do so. Caching is disabled in debug mode.
您可以在http://bottlepy.org/docs/dev/tutorial.html#debug-mode找到它
bottle.debug(True)
In this mode, Bottle is much more verbose and provides helpful debugging information whenever an error occurs. It also disables some optimisations that might get in your way and adds some checks that warn you about possible misconfiguration.
Here is an incomplete list of things that change in debug mode:
The default error page shows a traceback.
Templates are not cached.
Plugins are applied immediately.
如果这仍然没有帮助,请进行一些浏览 https://github.com/bottlepy/bottle/blob/master/bottle.py#L3937
class SimpleTemplate(BaseTemplate):
def prepare(self,
escape_func=html_escape,
noescape=False,
syntax=None, **ka):
self.cache = {}
...
这似乎清除了缓存。
关于python Bottle网络服务器缓存html文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49804021/
我正在开发一个基于 Python 的应用程序(HTTP -- REST 或 jsonrpc 接口(interface)),它将用于生产自动化测试环境。这将连接到运行所有测试脚本的 Java 客户端。即
我正在关注Recipes的bottle框架。 当我尝试下面的代码时 #filename: mywebapp.py from bottle import Bottle, run, request app
我通常使用method version处理 Bottle 中的路由 bottle.route("/charge", "GET", self.charge) bottle 文档严重依赖 @route 装
如何在 Bottle 框架中执行基本身份验证?在 flask 中我曾经: def check( username, password ): # This function is called
是否可以在同一应用程序(同一端口)中托管一个普通 Bottle 应用程序和一个 WebSocket 应用程序(例如: https://github.com/defnull/bottle/blob/ma
我有使用 python 2.7.2、bottle 0.10.9 和“瑞士军刀” scrapy 0.14.1 编写的简单 REST API。 简单来说,只有一种方法 (myserver:8081/dop
嗨,有没有办法优雅地关闭 Bottle 服务器。在某种程度上,它应该能够在最终停止之前执行几个步骤。这对于线程和数据库状态等的一些清理至关重要,以避免重新启动期间的损坏状态。 我正在使用 mod ws
我正在尝试让服务器发送事件在Python中工作,所以我找到了一些演示代码,令我惊讶的是,它只部分工作,我不明白为什么。我从here获取代码并进行了一些小的更改,这样我就可以看到什么在起作用(我包括了一
有没有办法让我的网站可以通过我所连接的网络访问? from bottle import route, run, template @route('/hello/') def index(name):
如果我直接从 Bottle 导入 post、get 和 jinja2_view,我就可以使用 jinja2_view 作为装饰器: from bottle import get, post, requ
我正在尝试将 Bottle.py 作为脚本内的进程运行,但我很沮丧,因为它没有按我的预期工作。这是我的脚本的假设/简化表示。我尝试添加尽可能多的评论。 magball.py import serial
(免责声明:我正在发现 python) 使用以下代码: @route('/test', method='POST') def index_view(): image = request.fil
我有一个 Bottle 服务器在端口 8080 上运行,使用“gevent”服务器。我使用这个服务器来支持一些简单的“服务器发送事件”。 我的问题可能与不知道我的设置是如何工作有关。我希望有人能花时间
我最近接触了 Bottlepy,这几乎是我第一次使用模板引擎。(之前我会简单地用传统 PHP 制作我需要的东西) 我的问题是这样的,假设我有一个基本布局(一个简单的 HTML/CSS 布局),并且,例
我如何管理 Bottle 中的多个应用程序,一次运行? 应用 0 from bottle import Bottle app0 = Bottle() @app0.route('/app0/') def
我将 bottle 用于一个显示日历并允许用户指定年份和月份的简单应用。定义了以下路由: '/' # 当前年份和当前月份 '/year' #年和当月 '/year/month' #年月 但是,无法识别
我正在使用 Bottle 框架。我已经设置了 @error 装饰器,所以我能够显示我自定义的错误页面,如果发生任何 500 错误我也可以发送电子邮件,但我需要在电子邮件中发送完整的回溯。有谁知道如何将
我有这样的目录结构: . ├── controller │ ├── FooController.py │ ├── __init__.py │ ├── main.py FooController
我在 bottle 中使用 html,在“index.html”中我导入外部 JS 和 CSS。 但是加载页面时,找不到css和js。 我的项目结构: testBottle.py 中的代码: impo
嗨,我是 python 和 bottle 的新手 我有一个网站 这是结构 |root index.py |classes session.py 如何从 index.py 访问
我是一名优秀的程序员,十分优秀!