Hello folks,
Yesterday I did manage to serve my web simple application from my android phone. By following some simple steps you can do it too, it’s ridiculous easy!
First of all I have to say that this experimental is tested and worked only with the Iris web framework, written in Golang and Android version 5.1.
Steps
Open your android device and follow the steps below.
- Install & open termux
- Execute the following commands by order
$ pkg install git
$ pkg install golang
$ export GOPATH=/data/data/com.termux/files/home/go
$ go get github.com/kataras/iris/v12@latest
$ cd /data/data/com.termux/files/home/go/src/github.com/kataras/iris/_examples/hello-world
$ go run main.go
- Open your favorite browser and navigate to http://localhost:8080
For those who understand better by watching media, I produced a simple video tutorial too!
That’s all, pretty simple. Right?
Share your thoughts about this post and let me know what awesome apps you’re planing to build with Go + Iris!
The full source code of the web app we ran is located there.
If you have any further questions please feel free to leave a comment below or open a discussion with us.
This article was originally posted at medium
Top comments (21)
I love it! Thanks for sharing. I love how you can do just about anything with an Android device.
I dont think so, I could do it with other frameworks, since almost 2 years. Almost all other server frameworks in any language that can compile to arm or arch64 could be used to run an server. Or even nginx.
Probably yes, but I didn't test it and I can't recommend things that myself didn't go through. This article is a good resource for everyone.
I agree,and also know you authored Iris, but dont you think. Saying "only" is too much?
NGINX is available out of the box on termux pkg repo, do you think that that "only iris works" is justified? For those not into GO ecosystem nginx is much more popular, even apache is available out of the box in termux packages.
Im just concerned about others thinking this is the only way, while they have out of the box solutions.
Ok : "Hello world" ( with Dolphin browser works )..
Followed step by step : Server up ; after : localhost:8080 in DU browser and Samsung browser - google main search comes on. Clues ? thanks africasiaeuro
You can try to prepend the "http://" or change the "localhost:8080" to something like "127.0.0.1:8080"
Hi Makis, just for thoughts. The Android server works. What can you do with it?
Couldn't you just replace
$ export GOPATH=/data/data/com.termux/files/home/go
with
$ export GOPATH=$PWD
?
You only could if you had cd in go, which he hadn't in here. Also, it's easier to add the long path assuming some may not realize what pwd they're in or not be well verse in Linux :)
Hi, I could use some help getting this to run. Does it still work?
Hello Lindelani, of course, it still works, what help do you need? We can have live chat if you want: chat.iris-go.com
Hi Makis, yes that would be excellent thank you. I'll head to the link right now.
thepracticaldev.s3.amazonaws.com/i... This is a screenshot of what happens whenever I try to run it.
Ooh, might try this later. I've got a bunch of Android 5.1 phones that could be useful!
I did the same with a node server. You just have to type pkg install nodejs. Works like a charm!
W-w-waaaiiit. What is
pkg
and where does it come from? Has it always been around? Would've LOVED to install Linux software using some package manager in the past.Great ! Another reason for me to actively follow Iris project.