基于beego的Controller设计,只需要匿名组合beego.Controller就可以,如下所示: type xxxController struct { beego.Controller } beego.Controller实现了接口beego.ControllerInterface,其源码定义如下: // ControllerInterface is an interface to uniform all controller handler. type ControllerInte
前言:当我们想在页面上给客户端返回一个当前时间,一些初学者可能会很自然的想到用占位符,字符串拼接来达到我们想要的效果,但是这样做会有一个问题,HTML被直接硬编码在 Python代码之中. 1 2 3 4 def current_datetime(request): now = datetime.datetime.now() html = "<html><body>It is now %s.</body></html>"