DEV Community

Gerasimos (Makis) Maropoulos
Gerasimos (Makis) Maropoulos

Posted on • Edited on

How to Turn an Android Device into a Web Server

article cover

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
Enter fullscreen mode Exit fullscreen mode

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)

Collapse
 
jakevossen5 profile image
Jake Vossen

I love it! Thanks for sharing. I love how you can do just about anything with an Android device.

Collapse
 
anaganisk profile image
Sai Kiran

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.

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.

Collapse
 
kataras profile image
Gerasimos (Makis) Maropoulos • Edited

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.

Collapse
 
anaganisk profile image
Sai Kiran

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.

Collapse
 
africasiaeuro profile image
Heinz Rainer

Ok : "Hello world" ( with Dolphin browser works )..

Collapse
 
africasiaeuro profile image
Heinz Rainer

Followed step by step : Server up ; after : localhost:8080 in DU browser and Samsung browser - google main search comes on. Clues ? thanks africasiaeuro

Collapse
 
kataras profile image
Gerasimos (Makis) Maropoulos

You can try to prepend the "http://" or change the "localhost:8080" to something like "127.0.0.1:8080"

Collapse
 
africasiaeuro profile image
Heinz Rainer

Hi Makis, just for thoughts. The Android server works. What can you do with it?

Collapse
 
doshirae profile image
Doshirae

Couldn't you just replace
$ export GOPATH=/data/data/com.termux/files/home/go
with
$ export GOPATH=$PWD
?

Collapse
 
rhymsy profile image
rhymsy

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 :)

Collapse
 
saikyoprogrammer profile image
Lindelani

Hi, I could use some help getting this to run. Does it still work?

Collapse
 
kataras profile image
Gerasimos (Makis) Maropoulos

Hello Lindelani, of course, it still works, what help do you need? We can have live chat if you want: chat.iris-go.com

Collapse
 
saikyoprogrammer profile image
Lindelani

Hi Makis, yes that would be excellent thank you. I'll head to the link right now.

Collapse
 
saikyoprogrammer profile image
Lindelani

thepracticaldev.s3.amazonaws.com/i... This is a screenshot of what happens whenever I try to run it.

Collapse
 
andy profile image
Andy Zhao (he/him)

Ooh, might try this later. I've got a bunch of Android 5.1 phones that could be useful!

Collapse
 
clerton profile image
Clerton Araujo

I did the same with a node server. You just have to type pkg install nodejs. Works like a charm!

Collapse
 
22samuelk profile image
Samuel

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.

Collapse
 
corebreaker profile image
Frédéric Meyer

Great ! Another reason for me to actively follow Iris project.