Пример #1
0
func main() {

	arguments := os.Args[1:]
	port := arguments[0]
	server := martini.Classic()
	server.Use(martini.Static("../public"))
	server.Use(martini.Static("../assets/javascript/app"))
	server.Use(nocache.UpdateCacheHeaders())
	fmt.Printf(" listening on port %s\n", port)
	log.Fatal(http.ListenAndServe(":"+port, server))

}
Пример #2
0
func main() {
	server := martini.Classic()
	server.Use(martini.Static("../public"))
	server.Use(martini.Static("../assets/javascript/app"))
	server.Use(nocache.UpdateCacheHeaders())
	server.Use(cors.Allow(&cors.Options{
		AllowOrigins:     []string{"https://localhost:3000"},
		AllowMethods:     []string{"POST", "GET"},
		AllowHeaders:     []string{"Origin", "Content-Type"},
		ExposeHeaders:    []string{"Content-Length"},
		AllowCredentials: true,
	}))
	server.Get("/")
	server.Post("/calculator", Calculate)

	log.Fatal(http.ListenAndServe(":3000", server))
}