Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

关于静态文件夹 #4

Closed
muei opened this issue Aug 4, 2014 · 5 comments
Closed

关于静态文件夹 #4

muei opened this issue Aug 4, 2014 · 5 comments

Comments

@muei
Copy link

muei commented Aug 4, 2014

新建文件public/index.html
直接输入localhost:xxx 访问报404错误

@unknwon
Copy link
Contributor

unknwon commented Aug 4, 2014

你这样提问对解决问题毫无帮助,请提供更多代码、目录结构等信息后再重启issue

@unknwon unknwon closed this as completed Aug 4, 2014
@muei
Copy link
Author

muei commented Aug 5, 2014

之前在群里提过,小黑说是设计如此。
我的意思是,静态文件夹(public)下的index.html,直接访问请求http://localhost:xxx/ 是无法访问的,http://localhost:xxx/index.html才可以访问。
我是想确认下是否本身设计如此,因为我用过很多其他的框架 比如martini,静态文件夹下的index文件是可以直接默认访问的,而且优先于注册的路由

@unknwon
Copy link
Contributor

unknwon commented Aug 5, 2014

我按照你说的测试了,没有出现你说的问题,是可以访问index.html的。

@muei
Copy link
Author

muei commented Aug 5, 2014

我的是win8.1 64位环境下。

package main

import (
    "github.com/Unknwon/macaron"
)

func main() {
    m := macaron.Classic()
    // m.Get("/", func() (int, string) {
    //  return 200, "helloworld"
    // })
    m.Run()
}

目录结构:
example
./public
./public/index.html
./main.go

运行程序go run main.go
浏览器访问http://localhost:4000/,报404

@unknwon
Copy link
Contributor

unknwon commented Aug 5, 2014

复制你的代码和目录结构,mac下还是没有问题。。我也用的go run。回头win下再测试下

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants