uAdmin the Golang Web Framework

uAdmin is easy to use, blazing fast and secure. It is a simple yet powerful web framework for building web applications.

Before you proceed to the installation, go over to the Getting Started to see the prerequisite requirements.

Installation

$ go get -u github.com/uadmin/uadmin/...

To test if your installation is fine, run the uadmin command line:

$ uadmin
Usage: uadmin COMMAND [-e email] [-d domain]
This tools allows you to publish your project online

Commands:
publish         This publishes your project online
prepare         Generates folders and prepares static and templates
version         Shows the version of uAdmin

Arguments:
-e, --email     Your email. This is required for you to be able to maintain your project.
-d, --domain    You can choose your domain name which will customize your URL

Get full documentation online:
https://uadmin.readthedocs.io/en/latest/

Your First App

Let’s build your first app which is a Todo list. First, we will create a folder for your project and prepare it.

$ mkdir -p ~/go/src/github.com/your_name/todo
$ cd ~/go/src/github.com/your_name/todo
$ uadmin prepare
[   OK   ]   Created: /home/pc_name/go/src/github.com/your_name/todo/models
[   OK   ]   Created: /home/pc_name/go/src/github.com/your_name/todo/api
[   OK   ]   Created: /home/pc_name/go/src/github.com/your_name/todo/views
[   OK   ]   Created: /home/pc_name/go/src/github.com/your_name/todo/media
[   OK   ]   Created: /home/pc_name/go/src/github.com/your_name/todo/handlers
[   OK   ]   Created: /home/pc_name/go/src/github.com/your_name/todo/static
[   OK   ]   Created: /home/pc_name/go/src/github.com/your_name/todo/templates

Use your favorite editor to create “main.go” inside that path. Put the following code in “main.go”.

package main

import (
    "github.com/uadmin/uadmin"
    "time"
)

// Todo model ...
type Todo struct {
        uadmin.Model
        Name        string
        Description string `uadmin:"html"`
        TargetDate  time.Time
        Progress    int `uadmin:"progress_bar"`
}

func main() {
        uadmin.Register(Todo{})
        uadmin.StartServer()
}

Important

In Windows, you need to use localhost in order to run your application (e.g. http://localhost:8080). Another way is to set your loopback Internet protocol (IP) address by using uadmin.BindIP to establish an IP connection to the same machine or computer being used by the end-user.

Sample:

func main(){
    // Put this code before uadmin.StartServer
    uadmin.BindIP = "127.0.0.1"
}

Now to run your code (Linux and Apple macOS):

$ go build; ./todo
[   OK   ]   Initializing DB: [9/9]
[   OK   ]   Initializing Languages: [185/185]
[  INFO  ]   Auto generated admin user. Username: admin, Password: admin.
[   OK   ]   Server Started: http://0.0.0.0:8080
         ___       __          _
  __  __/   | ____/ /___ ___  (_)___
 / / / / /| |/ __  / __  __ \/ / __ \
/ /_/ / ___ / /_/ / / / / / / / / / /
\__,_/_/  |_\__,_/_/ /_/ /_/_/_/ /_/

In Windows:

> go build && todo.exe
[   OK   ]   Initializing DB: [9/9]
[   OK   ]   Initializing Languages: [185/185]
[  INFO  ]   Auto generated admin user. Username: admin, Password: admin.
[   OK   ]   Server Started: http://0.0.0.0:8080
         ___       __          _
  __  __/   | ____/ /___ ___  (_)___
 / / / / /| |/ __  / __  __ \/ / __ \
/ /_/ / ___ / /_/ / / / / / / / / / /
\__,_/_/  |_\__,_/_/ /_/ /_/_/_/ /_/

If you go to the explorer, you will notice that there are automatically generated .key and .salt files hidden in your computer. .key is used for authentication process to assure that the key of the user (“person A” for instance) held by “person B” belongs to the authenticated user which is “person A”. .salt is extra salt added to password hashing. They add an extra security to your application. Once they have been deleted, no one can login to your application unless you use the recovery admin account that is automatically generated by your terminal.

_images/keysalt.png

Open your browser and type the IP address above. Then login using “admin” as username and password.

_images/loginform.png

You will be greeted by the uAdmin dashboard. System models are built in to uAdmin, and the rest are the ones we created, in this case TODOS model. Open the TODOS model.

_images/todoshighlightedlog.png

Click Add New TODO.

_images/todomodel.png

Fill up the fields like in the example below:

_images/todomodelcreate.png

Save it and new data will be added to your model.

_images/todomodeloutput.png

Well done! You have created your first application.

Publish your app

To take your app live, it is simple:

$ uadmin publish
Enter your email: me@example.com
Your project will be published to https://my-proj.uadmin.io
Enter the name of your sub-domain (my-proj) [auto]: my-app
Did you change the default port from 8080?
This is the port you have in uadmin.Port = 8080
Enter the port that your server run on [8080]:
[   OK   ]   Compressing [420/420]
[   OK   ]   Your application has been uploaded
[   OK   ]   Application installed succesfully
[   OK   ]   Your Project has been published to https://my-app.uadmin.io/

Update uAdmin to latest version

Open your terminal and apply the following commands:

$ cd ~/go/src/github.com/uadmin/uadmin/cmd/uadmin
$ go install
$ uadmin version
[  INFO  ]   0.2.0