Skip to content

Golang framework for simplifying web development.

License

Notifications You must be signed in to change notification settings

aquiffoo/goblet

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

A simple and lightweight server-side web framework for Go, that works like Flask, but in an ambient that is much faster than Python. You can send data through the data interface and use HTML files as templates.

Installation

go get github.com/aquiffoo/goblet

Usage

package main

import (
	"net/http"

	"github.com/aquiffoo/goblet"
)

func main() {
	app := goblet.New(true)

	app.Handle("/", func(w http.ResponseWriter, r *http.Request) {
		data := map[string]interface{}{
			"title": "Home",
		}

		app.Render(w, "index.html", data)
	})

	app.Handle("/about", func(w http.ResponseWriter, r *http.Request) {
		data := map[string]interface{}{
			"title": "About",
		}

		app.Render(w, "about.html", data)
	})

	err := app.Serve("8080")
	if err != nil {
		panic(err)
	}
}
<!-- index.html -->
<!DOCTYPE html>
<html lang="{{ .lang }}">
<head>
    <meta charset="{{ .charset }}">
    <title>{{ .title }}</title>
    <link rel="stylesheet" href="{{ url_for "static/style.css" }}">
</head>
<body>
    <h1>Welcome to Goblet</h1>
    <p>This is a demo for Goblet, my first Go framework.</p>
    <a href="{{ url_for "about" }}">About</a>
</body>
</html>
<!-- about.html -->
<!DOCTYPE html>
<html lang="{{ .lang }}">
<head>
    <meta charset="{{ .charset }}">
    <title>{{ .title }}</title>
    <link rel="stylesheet" href="{{ url_for "static/style.css" }}">
</head>
<body>
    <h1>About Page</h1>
    <p>This page is rendered using Goblet templates.</p>
    <a href="{{ url_for "index" }}">Go Back</a>
</body>
</html>

Documentation

The documentation can be found here.

License

This project is licensed under the CC BY-NC 4.0 license.

Authorship

This was entirely written by aquiffoo. Contributors can add their names to the AUTHORS file.

About

Golang framework for simplifying web development.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages