예제 #1
0
파일: bloody.go 프로젝트: Quasimo/bloody.go
func main() {
	config = loadConfig()
	initMongo()
	initLayout()
	h = new(session.MHandler)
	h.SetSession(mSession)
	web.Config.StaticDir = config.Get("staticdir")
	web.Get("/", index)
	web.Get("/post/list", listPosts)
	web.Get("/post/([A-Za-z0-9]+)", readPost)
	web.Get("/page/([a-z0-9\\-]+)\\.html", readPage)
	web.Get("/admin", adminIndexGet)
	web.Get("/admin/post/new", newPostGet)
	web.Post("/admin/post/new", newPostPost)
	web.Get("/admin/post/list", listPost)
	web.Get("/admin/post/edit/(.*)", editPostGet)
	web.Post("/admin/post/edit/(.*)", editPostPost)
	web.Get("/admin/post/del/(.*)", delPost)
	web.Get("/admin/login", adminLoginGet)
	web.Post("/admin/login", adminLoginPost)
	web.Get("/admin/page/new", adminNewPageGet)
	web.Post("/admin/page/new", adminNewPagePost)
	web.Get("/admin/page/list", adminListPagesGet)
	web.Get("/admin/page/edit/(.*)", adminEditPageGet)
	web.Post("/admin/page/edit/(.*)", adminEditPagePost)
	web.Get("/admin/page/del/(.*)", adminDelPage)
	web.Run(config.Get("host") + ":" + config.Get("port"))
}
예제 #2
0
파일: main.go 프로젝트: noppanit/gon
func main() {
	starter.Start()
	web.Config.StaticDir = "web-app/"
	web.Post("/(.*)", starter.Get)
	web.Get("/(.*)", starter.Get)
	web.Run("0.0.0.0:8080")
}
예제 #3
0
func main() {
	viewInit()
	mysqlInit()

	web.Get("/edit/(.*)", edit)
	web.Get("/(.*)", show)
	web.Post("/(.*)", update)
	web.Run("0.0.0.0:1111")
}
예제 #4
0
func main() {
	web.Get("/said", func() string { return tmpl })
	web.Post("/say", func(ctx *web.Context) string {
		input = ctx.Request.Form["said"][0]
		return `<a href="/final">Click Here</a>`
	})
	web.Get("/final", func() string { return "You said " + input })
	web.Run("0.0.0.0:9999")
}
예제 #5
0
func RunWebServer(line *util.ChannelLine) {
	util.WebOut = line
	web.SetLogger(log.New(new(dummy), "", 0))
	web.Config.CookieSecret = util.Settings.CookieSecret()
	web.Get("/Liberator/(.*)", get)
	web.Get("/(.*)", index)
	web.Post("/Liberator/(.*)", post)
	web.Run("0.0.0.0:" + strconv.Uitoa(util.Settings.WebPort()))
}
예제 #6
0
파일: kurz.go 프로젝트: vormplus/kurz.go
// main function that starts everything
func main() {
	flag.Parse()
	cfgFile := flag.Arg(0)
	err := bootstrap(cfgFile)
	if err == nil {
		listen := config.GetStringDefault("listen", "0.0.0.0")
		port := config.GetStringDefault("port", "9999")
		web.Run(fmt.Sprintf("%s:%s", listen, port))
	}
}
예제 #7
0
파일: logger.go 프로젝트: TheOnly92/web.go
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")
}
예제 #8
0
파일: gourl.go 프로젝트: hernan43/gourl
func main() {
	/*setup redis connection*/
	redisClient.Addr = "localhost:6379"
	redisClient.Db = 13

	/*setup web.go stuff*/
	web.Get("/", index)
	web.Get("/s/(.*)", show)
	web.Get("/u/(.*)", redirect)
	web.Post("/shorten", shorten)
	web.Run("0.0.0.0:8080")
}
예제 #9
0
func main() {
	// Main template
	tpl = kasia.New()
	err := tpl.Parse(tpl_txt)
	if err != nil {
		fmt.Println("Main template", err)
		return
	}

	// This example can work in strict mode
	tpl.Strict = true

	// Web.go
	web.Get("/(.*)", hello)
	web.Run("0.0.0.0:9999")
}
예제 #10
0
func main() {
	rand.Seed(time.Nanoseconds())
	web.Config.CookieSecret = "7C19QRmwf3mHZ9CPAaPQ0hsWeufKd"
	web.Get("/said", func() string { return form })
	web.Post("/say", func(ctx *web.Context) string {
		uid := strconv.Itoa64(rand.Int63())
		ctx.SetSecureCookie("user", uid, 3600)
		users[uid] = ctx.Request.Params["said"]
		return `<a href="/final">Click Here</a>`
	})
	web.Get("/final", func(ctx *web.Context) string {
		uid, _ := ctx.GetSecureCookie("user")
		return "You said " + users[uid]
	})
	web.Run("0.0.0.0:9999")
}
예제 #11
0
func main() {
	Db = NewMongoDB()
	Db.Connect()
	web.Config.CookieSecret = "7C19QRmwf3mHZ9CPAaPQ0hsWeufKd"
	web.Get("/", index)
	web.Get("/post", post)

	web.Get("/rss.xml", rss)
	web.Get("/index.php/feed/", rss)
	web.Get("/index.php/feed/atom/", rss)

	web.Get("/admin/edit", editGet)
	web.Post("/admin/edit", editPost)

	web.Get("/admin", adminGet)
	web.Post("/admin", adminPost)

	web.Run("0.0.0.0:9876")

}
예제 #12
0
func main() {
	config = loadConfig()
	initMongo()
	initLayout()
	h = new(session.MHandler)
	h.SetSession(mSession)
	blogConfig = PreferenceInit()
	path, _ := os.Getwd()
	web.Config.StaticDir = path + "/" + config.Get("staticdir")
	i := &Index{}
	a := &Admin{}
	web.Get("/", web.MethodHandler(i, "Index"))
	web.Get("/post/list", web.MethodHandler(i, "ListPosts"))
	web.Get("/post/([A-Za-z0-9]+)", web.MethodHandler(i, "ReadPost"))
	web.Get("/page/([a-z0-9\\-]+)\\.html", web.MethodHandler(i, "ReadPage"))
	web.Post("/post/([A-Za-z0-9]+)/comment/new", web.MethodHandler(i, "NewComment"))
	web.Get("/admin", web.MethodHandler(a, "IndexGet"))
	web.Get("/admin/preferences", web.MethodHandler(a, "PreferencesGet"))
	web.Post("/admin/preferences", web.MethodHandler(a, "PreferencesPost"))
	web.Get("/admin/post/new", web.MethodHandler(a, "NewPostGet"))
	web.Post("/admin/post/new", web.MethodHandler(a, "NewPostPost"))
	web.Get("/admin/post/list", web.MethodHandler(a, "ListPost"))
	web.Post("/admin/post/list", web.MethodHandler(a, "BulkActions"))
	web.Get("/admin/post/edit/(.*)", web.MethodHandler(a, "EditPostGet"))
	web.Post("/admin/post/edit/(.*)", web.MethodHandler(a, "EditPostPost"))
	web.Get("/admin/post/del/(.*)", web.MethodHandler(a, "DelPost"))
	web.Get("/admin/login", web.MethodHandler(a, "LoginGet"))
	web.Post("/admin/login", web.MethodHandler(a, "LoginPost"))
	web.Get("/admin/page/new", web.MethodHandler(a, "NewPageGet"))
	web.Post("/admin/page/new", web.MethodHandler(a, "NewPagePost"))
	web.Get("/admin/page/list", web.MethodHandler(a, "ListPagesGet"))
	web.Get("/admin/page/edit/(.*)", web.MethodHandler(a, "EditPageGet"))
	web.Post("/admin/page/edit/(.*)", web.MethodHandler(a, "EditPagePost"))
	web.Get("/admin/page/del/(.*)", web.MethodHandler(a, "DelPage"))
	web.Get("/admin/comment/del/(.*)/(.*)", web.MethodHandler(a, "DelComment"))
	web.Get("/admin/bloody/restart", web.MethodHandler(a, "RestartBloody"))
	web.Get("/rss", web.MethodHandler(i, "RSS"))
	web.Run(config.Get("host") + ":" + config.Get("port"))
}
예제 #13
0
func main() {

	conn := need_connection()
	var p Personne
	var c Car
	Personnes := gouda.M(p)
	Cars := gouda.M(c)
	Cars.BelongsToKey(Personnes, "owner", "Owner_id")
	Personnes.HasManyKey(Cars, "cars", "Owner_id")

	//web.Get("/(.*)", hello)
	web.Get("/new_person/", new_person)
	web.Get("/persons/", persons)
	web.Get("/", persons)
	web.Get("/person/(.*)", person_detail)
	web.Get("/edit_person/(.*)", person_edit)
	web.Get("/delete_person/(.*)", person_delete)
	web.Post("/person", create_person)
	web.Post("/update_person", update_person)
	web.Run("0.0.0.0:9999")
	conn.Close()
}
예제 #14
0
func main() {
	// Main template
	tpl = kasia.New()
	err := tpl.Parse(
		"<html><body>Request #$cnt: $txt<br>\n$subtpl.Nested(subctx)</body></html>")
	if err != nil {
		fmt.Println("Main template", err)
		return
	}

	// Nested template
	data.subtpl = kasia.New()
	err = data.subtpl.Parse("$for i+, v in vals: $i: $v<br>\n$end")
	if err != nil {
		fmt.Println("Nested template", err)
		return
	}

	// Web.go
	web.Get("/(.*)", hello)
	web.Run("0.0.0.0:9999")
}
예제 #15
0
func main() {
	flag.Parse()
	Init(NewDiskvStore(*dir, uint32(*maxsz)), *pwhash)
	log.Printf("nobodycares engine starting up...")

	web.Get("/", get_root)
	web.Get("/from/([0-9a-f]+)", get_from)
	web.Get("/post", get_post)
	web.Get("/edit/([0-9a-f]+)", get_edit)
	web.Get("/([0-9a-f]+)/edit", get_edit)
	web.Get("/delete/([0-9a-f]+)", get_delete)
	web.Get("/([0-9a-f]+)/delete", get_delete)
	web.Get("/([0-9a-f]+)", get_specific_id)
	web.Get("/rss", get_rss)
	web.Get("/css/(.*)", get_css)

	web.Post("/post", post_post)
	web.Post("/edit", post_edit)
	web.Post("/delete", post_delete)

	web.Run(fmt.Sprintf("%s:%d", *host, *port))
}
예제 #16
0
파일: templates.go 프로젝트: tjweir/web.go
func main() {
	web.Get("/(.*)", hello)
	web.Run("0.0.0.0:9999")
}
예제 #17
0
파일: cheatdb.go 프로젝트: shellreef/gones
// Web interface
func (db *Database) Serve() {
	web.Get("/patches.js", func(w *web.Context) { // TODO: accept arguments to filter
		query := db.query("SELECT rom_address,rom_before,rom_after, cpu_address,value,compare, title,game.name FROM patch,code,effect,game WHERE patch.code_id=code.id AND code.effect_id=effect.id AND effect.game_id=game.id;") // TODO: get effect,game,cart

		w.SetHeader("Content-Type", "text/javascript", false)
		w.WriteString("var PATCHES = [\n")

		for query.Next() {
			var r struct {
				RomAddress int    "romAddress"
				RomBefore  string "romBefore"
				RomAfter   string "romAfter"
				CpuAddress int    "cpuAddress"
				Value      int    "value"
				Compare    *int   "compare"
				Title      string "title"
				GameName   string "gameName"
			}

			r.Compare = new(int)

			err := query.Scan(&r.RomAddress, &r.RomBefore, &r.RomAfter, &r.CpuAddress, &r.Value, &r.Compare, &r.Title, &r.GameName)
			if err != nil {
				panic(fmt.Sprintf("failed to Scan: %s", err))
			}
			// TODO: use JSON module, avoid XSS
			html, err2 := json.MarshalForHTML(r)

			if err2 != nil {
				panic(fmt.Sprintf("failed to marshal: %s", err2))
			}

			w.Write(html)
			w.WriteString(",\n")
		}
		w.WriteString("]\n")
	})

	web.Get("/games.js", func(w *web.Context) {
		w.SetHeader("Content-Type", "text/javascript", false)
		w.WriteString("[\n")

		//query := db.query("SELECT game.id,game.name,game.galoob_name,game.galoob_id, COUNT(effect.id) FROM game,effect WHERE effect.game_id=game.id GROUP BY game.id ORDER BY COUNT(effect.id) DESC;")
		query := db.query("SELECT game.id,game.name,game.galoob_name,game.galoob_id, COUNT(effect.id) FROM game,effect WHERE effect.game_id=game.id GROUP BY game.id ORDER BY game.name;")
		for query.Next() {
			var r struct {
				GameID       int    "id"
				GameName     string "name"
				GameGaloob   string "galoob"
				GameGaloobID string "galoobID"
				EffectCount  int    "effectCount"
			}

			err := query.Scan(&r.GameID, &r.GameName, &r.GameGaloob, &r.GameGaloobID, &r.EffectCount)
			if err != nil {
				panic(fmt.Sprintf("failed to Scan: %s", err))
			}

			html, err2 := json.MarshalForHTML(r)
			if err2 != nil {
				panic(fmt.Sprintf("failed to marshal: %s", err2))
			}
			w.Write(html)
			w.WriteString(",\n")
		}
		w.WriteString("]\n")
	})

	web.Get("/effects/(.*)", func(w *web.Context, gameIDstring string) {
		gameID, err := strconv.Atoi(gameIDstring)
		if err != nil {
			w.WriteString("Invalid game")
			return
		}

		// TODO: get game, all carts, and all codes for all carts
		//query := db.query("SELECT * FROM effect,cart,code WHERE effect.game_id=1 AND cart.game_id=effect.game_id AND code.cart_id=cart.id")

		w.WriteString(fmt.Sprintf("id=%d\n", gameID))
	})

	web.Get("/", func(w *web.Context) {
		root, _ := path.Split(os.Args[0])
		filename := path.Join(root, "..", "genie", "jsdis.html")
		f, err := os.Open(filename, os.O_RDONLY, 0)
		if err != nil {
			panic(fmt.Sprintf("failed to open %s: %s", filename, err))
		}

		io.Copy(w, f)
	})

	web.Get("/favicon.ico", func(w *web.Context) {
		// TODO: real favicon
		w.SetHeader("Content-Type", "image/png", false)
	})

	web.Run("0.0.0.0:9999")
}
예제 #18
0
파일: cookie.go 프로젝트: rcoh/modata
func main() {
	web.Get("/", index)
	web.Post("/update", update)
	web.Run("0.0.0.0:9999")
}
예제 #19
0
파일: params.go 프로젝트: noppanit/web.go
func main() {
	web.Get("/", index)
	web.Post("/process", process)
	web.Run("0.0.0.0:9999")
}
func main() {
	web.Get("/(.*)", webCallback)
	web.Run("0.0.0.0:9999")
}
예제 #21
0
func Start() {
	addr := GetConfig("interface") + ":" + GetConfig("port")
	web.Run(addr)
}
func main() {
	web.Get("/", hello)
	web.Get("/hellos", hellos)
	//    web.Get("/hellodb", hellodb)
	web.Run("localhost:80")
}
예제 #23
0
func main() {
	web.Get("/", index)
	web.Post("/multipart", multipart)
	web.Run("0.0.0.0:9999")
}
예제 #24
0
파일: main.go 프로젝트: iporsut/gon
func main() {
	web.Get("/(.*)", starter.Get)
	web.Run("0.0.0.0:8080")
}
예제 #25
0
파일: runner.go 프로젝트: tjweir/web.go
func main() { web.Run(hello.Routes, "0.0.0.0:9999") }