I'm using the Beegae package and Google Cloud SDK. My project works, but I'm having trouble accessing my CSS file. It's located in static\css in my project's root (I use Windows). I tried SetStaticPath, setting DirectoryIndex to true, and setting the static path directly. My html is
<link rel="stylesheet" href="/static/css/style.css" type="text/css" />
and I keep getting
INFO 2014-07-29 07:16:47,546 module.py:640] default: "GET /static/css/style.css HTTP/1.1" 404 2010
Currently my router code is
package routers
import (
"beegoapp2/controllers"
"github.com/astaxie/beegae"
)
func init() {
beegae.DirectoryIndex = true
beegae.SetStaticPath("/static/css", "static/css")
// beegae.StaticDir["/static"] = "static"
beegae.Router("/", &controllers.MainController{})
beegae.Router("/home/index", &controllers.MainController{})
beegae.Router("/band/add", &controllers.BandAddController{})
beegae.Router("/band/verify", &controllers.BandVerifyController{})
beegae.Router("/album/index/:id", &controllers.AlbumIndexController{})
beegae.Router("/album/add/:id", &controllers.AlbumAddController{})
beegae.Router("/album/verify/:id", &controllers.AlbumVerifyController{})
beegae.Router("/home/genrelist", &controllers.GenreListController{})
beegae.Router("/home/bygenre/:id", &controllers.ByGenreController{})
}
If anyone can shed some light on this problem, I'd greatly appreciate it.
I solved the problem by changing my app.yaml. I added the following lines to the "handlers" section:
- url: /static/css
static_dir: static/css
mime_type: "text/css"
I suggest a similar change to anyone having trouble with static files while using Google App Engine.
Ross Albertson's answer didn't worked for me. Here is my solution for this problem. Change the app.yaml file's handlers part as follows...
handlers:
- url: /static
static_dir: ../static
- url: /.*
script: _go_app
This will be helpful not only for css but also for every other files like js, images etc.