About template HTML file location

331 views
Skip to first unread message

Demin Li

unread,
Aug 21, 2013, 6:18:59 AM8/21/13
to google-ap...@googlegroups.com
Hi, all,

I just started using Go on GAE.

When I was using GAE Go SDK locally the app works well

But after I pushed the files to server . 

It always said HTML page is not found.

Inline image 1

This is structure of files

and the YAML file 

application: myowngaetestapp
version: 1
runtime: go
api_version: go1

handlers:
- url: /static
  static_dir: static

- url: /.*
  script: myowngaetestapp.application



And this is the error log

panic: open /base/data/home/apps/s~myowngaetestapp/1.369657101922042571/index.html: no such file or directory
runtime.panic go/src/pkg/runtime/panic.c:230
html/template.Must go/src/pkg/html/template/template.go:284
app.getTemplate app/app.go:323
app.Context.Render app/app.go:170
app.Context.Show app/app.go:166
demo.index demo/demo.go:16
app.func·001 app/app.go:269
net/http.HandlerFunc.ServeHTTP go/src/pkg/net/http/server.go:1150
net/http.(*ServeMux).ServeHTTP go/src/pkg/net/http/server.go:1417
appengine_internal.executeRequestSafely go/src/pkg/appengine_internal/api_prod.go:250
appengine_internal.(*server).HandleRequest go/src/pkg/appengine_internal/api_prod.go:200
reflect.Value.call go/src/pkg/reflect/value.go:474
reflect.Value.Call go/src/pkg/reflect/value.go:345
_ _.go:316
runtime.goexit go/src/pkg/runtime/proc.c:280
Screen Shot 2013-08-21 at 6.14.53 PM.png

David Symonds

unread,
Aug 21, 2013, 9:23:27 PM8/21/13
to Demin Li, google-appengine-go
Can you show the relevant part of your code that calls template.Must? Can you make it use a relative filename?

(The bad handling of absolute paths is a known bug that will be fixed in the next release.)

Demin Li

unread,
Aug 21, 2013, 9:49:46 PM8/21/13
to David Symonds, google-appengine-go
Thanks , David,

I think I am using the relative filename 

the code I am writing is like:

tmp = template.Must(template.New(name).ParseFiles(getTemplateName(name)))

And from local server I print out the "name" is "index.html"

Thanks again.


On Thu, Aug 22, 2013 at 9:23 AM, David Symonds <dsym...@golang.org> wrote:
Can you show the relevant part of your code that calls template.Must? Can you make it use a relative filename?

(The bad handling of absolute paths is a known bug that will be fixed in the next release.)

--
You received this message because you are subscribed to the Google Groups "google-appengine-go" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-appengin...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

David Symonds

unread,
Aug 21, 2013, 9:51:32 PM8/21/13
to Demin Li, google-appengine-go
I would wager that you aren't using a relative filename because I
suspect getTemplateName(name) is making it absolute. What's the code
for that function?

Demin Li

unread,
Aug 21, 2013, 9:53:32 PM8/21/13
to David Symonds, google-appengine-go
Just add ".html" or not . I will remove this and try again .

func getTemplateName(name string) string {
if strings.Contains(name, ".") {
return Config.Templates + name
}
return Config.Templates + name + ".html"
}


David Symonds

unread,
Aug 21, 2013, 9:54:24 PM8/21/13
to Demin Li, google-appengine-go
What is Config.Templates?

Demin Li

unread,
Aug 21, 2013, 9:57:15 PM8/21/13
to David Symonds, google-appengine-go
thanks, David, 

yes, thats the problem. Now it works.

thank you so much . 

actually define config like this:

var Config = Settings{
Debug:     true,
Root:      "*",
Media:     "*",
Templates: "*",
}


On Thu, Aug 22, 2013 at 9:54 AM, David Symonds <dsym...@golang.org> wrote:
What is Config.Templates?

Reply all
Reply to author
Forward
0 new messages