[英]Load Angular2 Bootstrap template ng2-admin on Go server : download fail
I am new to this forum and a newbie in Angular2
and Golang
. 我是这个论坛的新手,并且是
Angular2
和Golang
的新手。 My issue is that I would like to try out a template on a Go
server. 我的问题是我想在
Go
服务器上试用模板 。
So, I created a main.go
file containing this main()
function : 因此,我创建了一个
main.go
文件,其中包含以下main()
函数:
func main() {
r := mux.NewRouter()
p := http.StripPrefix("/", http.FileServer(http.Dir("./src/")))
n := http.StripPrefix("/config", http.FileServer(http.Dir("./config/")))
r.PathPrefix("/config/").Handler(n)
r.PathPrefix("/").Handler(p)
fmt.Printf("Starting server on :33166 \n")
http.ListenAndServe(":33166", r)
}
and run go run main.go
on the project directory, but its fails in this request 然后在项目目录上运行
go run main.go
,但在此请求中失败
GET http://127.0.0.1:33166/webpack-dev-server.js
It might be very simple, but I couldnot figure it out. 这可能很简单,但我无法弄清楚。 So, any idea to how I'm able run the project on server would be appreciated.
因此,对我如何在服务器上运行项目的任何想法将不胜感激。 Thanks.
谢谢。
According to the ng2-admin installation guidelines , if you want to use ng2-admin with another backend (golang in your case), you need a release build using the following command: 根据ng2-admin安装指南 ,如果您想将ng2-admin与另一个后端(在您的情况下为golang)一起使用,则需要使用以下命令来发布版本:
npm run prebuild:prod && npm run build:prod
From installation guidelines: 根据安装指南:
This will clear up your dist folder (where release files are located), generate release build (...).
这将清除您的dist文件夹(发行文件所在的位置),生成发行版本(...)。 Now you can copy the sources from a dist folder and use it with any backend framework or simply put it under some web server.
现在,您可以从dist文件夹复制源,并将其与任何后端框架一起使用,或者将其放置在某些Web服务器下。
EDIT: Thanks to @PatrickWalker for his comments. 编辑:感谢@PatrickWalker的评论。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.