douxing5598 2013-06-18 05:47
浏览 680
已采纳

紧急:打开templates / base.html:系统找不到指定的路径

With shadynasty.biz/blog/2012/07/30/quick-and-clean-in-go link I am Trying to Create template in go programming. My project Structure is created with the Go-SDK google app engine. google_appengine/myapp/hello/hello.go file is present, then where to create template folder? I created the "template" folder in "hello" folder but getting error "panic: open templates/base.html: The system cannot find the path specified" and server stops running. What can be done?

  • 写回答

2条回答 默认 最新

  • dqd22496 2013-06-18 06:32
    关注

    using template on appengine is only posible if you pass the html from field, because of appengine rules you dont have access to the filesystem

    here is an example

    const loginTemplateHTML = `<html>
      <body>
        <form action="/login" method="post">
          <div><input name="username" type="text" /></div>
          <div><input name="password" type="password" /></div>
          <div><input type="submit" value="login"></div>
        </form>
      </body>
    </html>
        `    
    var loginTemplate = template.Must(template.New("Login").Parse(loginTemplateHTML))
    
    func login (w http.ResponseWriter, r *http.Request) {
        if err := loginTemplate.Execute(w,nil); err != nil {
             http.Error(w, err.Error(), http.StatusInternalServerError)
        }
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作