func main() { viewInit() web.Config.CookieSecret = "UXVpZXJvIGEgbWkgcGVxdWXxbyBoaWpvIE1hcmNvcw==" // Init API library jailgo.EntryInit() jailgo.ArtInit() jailgo.LoginInit() // Principal, comment and search pages web.Get("/", showblog) web.Get("/comment(.*)", entry) web.Get("/search", search) // Editing articles and comments web.Post("/updateArt", updateArt) web.Post("/updateEntry", updateEntry) // Login and Administration web.Post("/login", login) web.Get("/admin", admin) // Web server web.Run("0.0.0.0:9085") }
// TODO: One database per site func main() { // UserState with a Redis Connection Pool userState := permissions.NewUserState(0, true, ":6379") defer userState.Close() // The archlinux.no webpage, mainMenuEntries := ServeArchlinuxNo(userState, "/js/jquery-"+JQUERY_VERSION+".min.js") ServeEngines(userState, mainMenuEntries) // Compilation errors, vim-compatible filename web.Get("/error", webhandle.GenerateErrorHandle("errors.err")) web.Get("/errors", webhandle.GenerateErrorHandle("errors.err")) // Various .php and .asp urls that showed up in the log genericsite.ServeForFun() // TODO: Incorporate this check into web.go, to only return // stuff in the header when the HEAD method is requested: // if ctx.Request.Method == "HEAD" { return } // See also: curl -I // Serve on port 3009 for the Nginx instance to use web.Run("0.0.0.0:3009") }
func main() { flag.Parse() web.Get("/", func() string { return "Hello World" }) web.Run(":8080") }
func main() { bind_addr := flag.String("bind_ip", "127.0.0.1", "bind ip address") http_port := flag.Int("http_port", 9999, "listen http port") rpc_port := flag.Int("rpc_port", 9998, "listen rpc port") flag.Parse() go func() { addr, _ := net.ResolveTCPAddr("tcp", fmt.Sprintf("%s:%d", *bind_addr, *rpc_port)) listener, _ := net.ListenTCP("tcp", addr) rpcservice := new(RPCService) rpc.Register(rpcservice) rpc.HandleHTTP() for { conn, _ := listener.Accept() go rpc.ServeCodec(jsonrpc.NewServerCodec(conn)) } }() web.Get("/api/topics/([a-zA-Z0-9_\\-]+)/subscribers/([a-zA-Z0-9_\\-]+)/messages", APIGetTopicMessages) web.Post("/api/topics/([a-zA-Z0-9_\\-]+)/subscribers/([a-zA-Z0-9_\\-]+)/messages", APIPostTopicMessage) web.Get("/api/topics/([a-zA-Z0-9_\\-]+)", APIGetTopic) web.Post("/api/topics/([a-zA-Z0-9_\\-]+)", APIUpdateTopic) //web.Get("/api/topics", APIGetTopics) web.Get("/api/subscribers/([a-zA-Z0-9_\\-]+)", APIGetSubscriber) web.Post("/api/subscribers/([a-zA-Z0-9_\\-]+)", APIUpdateSubscriber) //web.Get("/api/topics/(.+)/subscribers/(.+)", APIGetTopicSubscriber) //web.Get("/api/topics/(.+)/subscribers", APIGetTopicSubscribers) web.Run(fmt.Sprintf("%s:%d", *bind_addr, *http_port)) }
func main() { web.Get("/vnstat/(.*)/(.*)", vnstat) web.Get("/dashboard/(.*)", dashboard) web.Get("/list", ifacelist) web.Get("/", home) web.Run(port) }
func main() { pckg_dir = os.Getenv("GOPATH") + "/src/github.com/couchbaselabs/showfast/" web.Config.StaticDir = pckg_dir + "app" config_file, err := ioutil.ReadFile(pckg_dir + "config.json") if err != nil { log.Fatal(err) } var config Config err = json.Unmarshal(config_file, &config) if err != nil { log.Fatal(err) } data_source = DataSource{config.CouchbaseAddress, config.BucketPassword} web.Get("/", home) web.Get("/admin", admin) web.Get("/release", release) web.Get("/feed", feed) web.Get("/all_metrics", data_source.GetAllMetrics) web.Get("/all_clusters", data_source.GetAllClusters) web.Get("/all_timelines", data_source.GetAllTimelines) web.Get("/all_benchmarks", data_source.GetAllBenchmarks) web.Get("/all_runs", all_runs) web.Get("/all_releases", data_source.GetAllReleases) web.Get("/all_feed_records", data_source.GetAllFeedRecords) web.Get("/get_comparison", get_comparison) web.Post("/delete", delete) web.Post("/reverse_obsolete", reverse_obsolete) web.Run(config.ListenAddress) }
func main() { web.Get("/getuserinfo", getlist) web.Get("/add/(.*)", addDrink) web.Get("/del/(.*)", delDrink) web.Run("127.0.0.1:9999") }
func main() { web.Get("/", indexPage) web.Post("/upload/(.*)", uploader) web.Get("/download/(.*)", downloader) bindHost := flag.String("bind", "0.0.0.0:8000", "bind to this address:port") realHost := flag.String("real-host", "", "real hostname client use to connect") realScheme := flag.String("real-scheme", "", "real scheme client use to connect") useXForwardedFor := flag.Bool("use-x-forwarded-for", false, "use X-Forwarded-For header for logging") logfile := flag.String("logfile", "", "log file (defaulg: stderr)") flag.Parse() appConfig = AppConfig{ *realScheme, *realHost, "http", *bindHost, *useXForwardedFor, } if *logfile != "" { web.SetLogger(NewRotateLog(*logfile, 1024*1024, 10, "", log.Ldate|log.Ltime)) } web.Run(appConfig.BindHost) }
func main() { pckgDir = os.Getenv("GOPATH") + "/src/github.com/tahmmee/greenboard/" web.Config.StaticDir = pckgDir + "app" configFile, err := ioutil.ReadFile(pckgDir + "config.json") if err != nil { log.Fatal(err) } var config Config err = json.Unmarshal(configFile, &config) if err != nil { log.Fatal(err) } // start web api api = new(Api) api.CouchbaseAddress = config.CouchbaseAddress api.DataSources = make(map[string]*DataSource) api.AddDataSource("server") api.AddDataSource("mobile") api.AddDataSource("sdk") web.Get("/", api.GetIndex) web.Get("/timeline", api.GetTimeline) web.Get("/breakdown", api.GetBreakdown) web.Get("/jobs", api.GetJobs) web.Get("/versions", api.GetVersions) web.Get("/categories", api.GetCategories) web.Get("/jobs_missing", api.GetMissingJobs) web.Run(config.ListenAddress) }
func main() { // Set the static directory for webgo path := os.Getenv("GOPATH") if path == "" { fmt.Println("GOPATH NOT SET") return } filepath := fmt.Sprintf("%s/../frontend/src/", path) web.Config.StaticDir = filepath // Setup logging log := make(l4g.Logger) // Create a default logger that is logging messages of FINE or higher l4g.AddFilter("file", l4g.FINE, l4g.NewFileLogWriter("error_log.log", false)) log.Close() // Setup the DB db.Init(path) // Parse command line arguments port := flag.Int("port", 80, "port number to start the server on") flag.Parse() url := fmt.Sprintf("0.0.0.0:%d", *port) // Start the server! serve.Routes() web.Run(url) }
func main() { go mainHub.Run() document_hubs = setupDocuments() chat_hubs = setupChats() // Get hostname if specified args := os.Args host := "0.0.0.0:8080" if len(args) == 2 { host = args[1] } parts := strings.Split(host, ":") fmt.Println(parts) web.Config.Addr = parts[0] web.Config.Port, _ = strconv.Atoi(parts[1]) web.Config.StaticDir = filepath.Join(os.Getenv("GOPATH"), "src/server/client/public") web.Get("/", home) web.Get("/ws", serveWs) web.Get("/rest/documents", getDocuments) web.Put("/rest/documents/(.*)", setDocumentTitle) web.Delete("/rest/documents/(.*)", deleteDocument) web.Get("/documents/(.*)", documentStream) web.Get("/chat/(.*)", chatStream) web.Run(host) }
func main() { fmt.Printf("Using config %s\n", conf.Path) fmt.Printf("Using models:\n") for _, m := range db.Models { t := reflect.TypeOf(m) fmt.Printf(" %s\n", fmt.Sprintf("%s", t)[1:]) } template.Init(conf.Config.TemplatePaths) fmt.Printf(conf.Config.String()) web.Config.StaticDir = conf.Config.StaticPath db.Connect(conf.Config.DbHostString(), conf.Config.DbName) db.RegisterAllIndexes() blog.AttachAdmin("/admin/") blog.Attach("/") app.AttachAdmin("/admin/") app.Attach("/") gallery.AttachAdmin("/admin/") gallery.Attach("/") web.Get("/$", blog.Index) web.Get("/(.*)", blog.Flatpage) app.AddPanel(&blog.PostPanel{}) app.AddPanel(&blog.UnpublishedPanel{}) app.AddPanel(&blog.PagesPanel{}) app.AddPanel(&gallery.GalleryPanel{}) web.Run(conf.Config.HostString()) }
func main() { fmt.Printf("Starting server ... ") web.Get("/iching/hexagrams/(.*)", hexagram) web.Get("/iching/hexagrams", allHexagrams) web.Get("/iching/reading", reading) web.Run("0.0.0.0:9999") }
func main() { logger := log.New(ioutil.Discard, "", 0) runtime.GOMAXPROCS(runtime.NumCPU()) web.Get("/(.*)", hello) web.SetLogger(logger) web.Run("0.0.0.0:8080") }
// Loop Func Register web interface func Loop() { // 注册web接口 web.Get("/ping", PingHandler) web.Get("/d", ResolveHandler) addr := fmt.Sprintf("%s:%s", appConfig.Listen, appConfig.Port) web.Run(addr) }
func main() { f, _ := os.Create("server.log") logger := log.New(f, "", log.Ldate|log.Ltime) runtime.GOMAXPROCS(runtime.NumCPU()) web.Get("/(.*)", hello) web.SetLogger(logger) web.Run("0.0.0.0:8080") }
func startServer(port string) { models.SetDatabase(&globalConfiguration.Database) web.Get("/?", index) generateRoutes() web.Run("0.0.0.0:" + port) }
func main() { web.Get("/()", IndexLoad) web.Get("/match/()", CompareNames) //web.Get("/test/(.*)", TestLoadHome) web.Get("/static/(.*)", Sendstatic) //STARTING PROCEDURE web.Run("0.0.0.0:8830") }
func main() { rand.Seed(time.Now().UnixNano()) port := os.Getenv("PORT") if port == "" { port = "9999" } web.Get("/(.*)", hello) web.Run(":" + port) }
func main() { // parse command line arguments flag.Parse() web.Get("/(list)", list) //web.Get("/(.*)", list) // web.SetLogger(glog) web.Run("0.0.0.0:9999") }
func main() { parse_flags() var config ViaConfig var configFile string args := flag.Args() if len(args) < 1 { configFile = "production.json" } else { configFile = args[0] } log.Print("loading config from " + configFile + "... ") config, err := LoadConfig(configFile) if err != nil { log.Printf("failed: %s\n", configFile, err.Error()) return } // Handle SIGINT and SIGKILL c := make(chan os.Signal, 1) signal.Notify(c, os.Interrupt, os.Kill, syscall.SIGABRT) go func() { for sig := range c { log.Printf("received %v, exiting...", sig) os.Exit(1) } }() procs := runtime.NumCPU() runtime.GOMAXPROCS(procs) log.Printf("starting server, running on %d cores...", procs) via := NewVia(Debug, expiry, config.DataDir) server := Server{Via: via, Host: config.Host, Port: config.Port, AllowedCountries: config.AllowedCountries} // Basic web.Get("/", Splash) web.Get("/status", server.GetServerStatus) // Dmatrix web.Post("/matrix/", server.PostMatrix) // Path web.Post("/paths", server.PostPaths) web.Match("OPTIONS", "/(.*)", Options) go func() { log.Println(http.ListenAndServe("localhost:6060", nil)) }() web.Run(fmt.Sprintf("%s:%d", config.Host, config.Port)) }
func main() { config, err := getConfig() if err != nil { panic(err.Error()) } web.Get("/([a-zA-Z0-9-]*)", handleSection) web.Get("/([a-zA-Z0-9-]+)/([0-9]+)", handlePaginatedSection) web.Get("/([a-zA-Z0-9-]+)/([a-zA-Z]{1}[a-zA-Z0-9-]*)", handlePage) web.Run(config.ServerIp) }
func main() { conn, err = redis.Dial("tcp", ":6379") if err != nil { // handle error } defer conn.Close() web.Post("(.*)", handleFilter) web.Run("0.0.0.0:9999") }
func main() { web.Get("/eject", func(ctx *web.Context) { ctx.ContentType("application/json") if err := eject.Eject(); err != nil { json.NewEncoder(ctx).Encode(&result{err.Error()}) } else { json.NewEncoder(ctx).Encode(&result{nil}) } }) web.Run(":8080") }
func main() { f, err := os.Create("server.log") if err != nil { println(err.Error()) return } logger := log.New(f, "", log.Ldate|log.Ltime) web.Get("/(.*)", hello) web.SetLogger(logger) web.Run("0.0.0.0:9999") }
func (srv *Server) Serve() { web.Get("/job/list", jobList) web.Get("/task/list", taskList) web.Get("/job/(.*)", jobGet) web.Post("/job", jobNew) web.Post("/job/run/(.*)", jobRun) web.Delete("/job/(.*)", jobRemove) web.Put("/job/(.*)", jobUpdate) addr, _ := globalCfg.ReadString("http_addr", ":9090") web.Run(addr) }
func main() { fmt.Println("onthefly ", onthefly.Version) // Connect the url for the HTML and CSS with the HTML and CSS generated from indexPage webhandle.PublishPage("/", "/style.css", indexPage) // Connect /circles.svg with the generated handle web.Get("/circles.svg", svgHandlerGenerator()) // Listen for requests at port 3000 web.Run(":3000") }
func main() { web.Get("/(.*)", welcome) web.Run("0.0.0.0:9999") LABEL1: for { for i := 0; i < 10; i++ { if i > 5 { break LABEL1 } } } fmt.Println("OK") // 冒泡排序 a := [...]int{2, 33, 11, 99, 55, 88} fmt.Println(a) for i, num := 0, len(a); i < num; i++ { for j := 0; j < i+1; j++ { if a[i] > a[j] { temp := a[i] a[i] = a[j] a[j] = temp } } } fmt.Println(a) a1 := [...]int{1, 2, 3, 4, 5} fmt.Println(a1) s := a1[:] fmt.Println(s) s1 := make([]map[int]string, 10) for k := range s1 { s1[k] = make(map[int]string, 1) s1[k][1] = "OK" } fmt.Println(s1) m1 := map[int]string{1: "a", 2: "b", 3: "c", 4: "d", 5: "e"} fmt.Println(m1) m2 := make(map[string]int) for k, v := range m1 { m2[v] = k } fmt.Println(m2) }
func main() { web.Get("/", views.Index) web.Get("/manage", views.Manage) web.Get("/manage/create", views.Create) web.Post("/manage/create", views.Create) web.Get("/manage/existing", views.Existing) web.Get("/manage/existing/remove/(.*)", views.Remove) web.Post("/manage/existing/remove/(.*)", views.Remove) web.Get("/manage/existing/(.*)", views.ExistingEdit) web.Post("/manage/existing/(.*)", views.ExistingEdit) web.Run("0.0.0.0:9999") }
func main() { port := flag.String("port", "8080", "The port that Sto should listen on. By default it is 8080.") procs := flag.Int("procs", 1, "The maximum number of processes that can be used by Go. The default value is one, but at least two are recommended in order to maximize performance.") flag.Parse() if *procs > runtime.NumCPU() { panic("Fatal error: You tried to use more processes than there are CPUs available") } runtime.GOMAXPROCS(*procs) startUp() web.Run("0.0.0.0:" + *port) }