Yahoo
Advertisement
Advertisement
Advertisement
Advertisement

4 ways Python has turned my Android phone into the ultimate homelab companion

The Python logo superimposed on an image of Termux running a program
The Python logo superimposed on an image of Termux running a program

Homelabs are a fun, worthwhile hobby for many of us, but you don't always need to invest hundreds or thousands of dollars into your setup. I try to think of it as more of a sandbox where I'm making things, learning, and experimenting with hardware and software.

Sometimes, you can experiment, create, and learn just as well with the smartphone you use every day (or an extra Android device you have lying around). One of my primary goals for this year (2026) was to learn a new programming language . No vibe coding for me, thanks.

While I'm well-versed in HTML5 and CSS, I've never truly dug into the exciting world of Python. So I started learning the language using a mix of W3 Schools tutorials , a few dusty old books, and one-on-one learning with a friend who knows the language well. With what I've learned so far, combined with my newfound Termux skills, I've been able to make a nifty little version of my home lab on the go with some very simple, yet useful, Python scripts.

Advertisement
Advertisement

Here are a few projects that I've worked on recently to turn my Samsung Z Fold 5 into a mini Python playground.

I made a local web server

The best way to transfer files wirelessly

A simple server using the http.server command in python

If there are two things I love, it's self-hosting and streamlined cable management. With a locally hosted web server, I get both. I take an excessive amount of pictures and occasionally shoot video with my phone. Transferring it to my computer for processing, editing, backup, and storage usually required going through the (admittedly very mild) hassle of plugging in a USB-C cable and giving it permission to transfer files via USB.

Either that, or I could share it via email, upload it to Google Drive, put it in Dropbox, or use WeTransfer. All of them are solid options, and there isn't really a problem here that needs a solution. I just wanted an excuse to set up a local web server with Python.

How I set up the server using http.server

It's as easy as picking a port and executing a single command

A network rack with wires coiled up everywhere

Photo by Ivan N on Unsplash

Setting up my server was very easy. I had to find my phone's IP address, which was located in the settings. But you could also use this command in Termux to find it:

Advertisement
Advertisement

Since I'm working on my Samsung, I have a dedicated folder under storage for my experiments.

  1. In Termux, I usedpython -m http.server 9090to start a server. I chose port 9090.

  2. After that, I pointed my browser to a new window and typed:http://, [my phone's IP address]:9090.

  3. This brought me to a page containing all my folders.

  4. I navigated for a bit, downloaded some of the larger files I'd saved over the years, and disconnected.

Python has a module built into it that implements a TCP server , so when you run it, it'll listen for any requests on certain ports. At a later date, I can build a dedicated server using Python and use my local server for quick and easy file transfers. I've been using it often and will continue to do so for the foreseeable future.

I automated music organization

I basically made a digital custodian for my music files

A simple music organizer python script running on Termux on mobile

The next Python project I tried out was creating a simple script to help me organize all the live shows I keep downloading from the Internet Archive. To begin with, I needed an OS module and the Shutil module. They're standard libraries for operating system interaction and file operations , so most likely they are the first modules most folks will add to Python right away.

Advertisement
Advertisement

In Termux, I created a file called 'organizer.py' and got to work. In the script itself, I listed commands to import OS and Shutil, followed by my path, defined a source and output location. It's just a string that tells Shutil to look at the end of a filename, and if it ends in .mp3, the utility will automatically move it to my 'tunes' folder.

At the end, I usedshutil.move(source_path, target_path)to have everything move from my downloads folder to my newly-created tunes folder. The script works like a charm. Since I have more control over what's happening here, it's like I have a personal custodian managing my music files.

Socket checks

A simple script lets me see what my local sockets are doing

A simple python script to check sockets runs in Termux with a python logo in the background

For most of this project, I decided to keep the scope fairly small and focus on practical things. So a script that does a socket check made plenty of sense. Now, I'm not going to get into the finer points of sockets and how they work, as Python wrote up some very nice documentation on the topic . Sometimes, you just need to keep it simple.

I wanted to have a quick way to see if any of my network ports were open, specifically, the ports for my FreshRSS and Jellyfin servers. So, I used Python'ssocketmodule withconnect_ex()to check if ports were open.

Advertisement
Advertisement

It turned out the port for my RSS feed and server were still closed, so they weren't listening for traffic. Which is just the way I like my self-hosted stuff to be for security purposes.

Python's http.server is read-onlyas a default mode, so you'll have to use other tools (like Flask, for example). If you want to get access from other devices, usepython -m http.server -- bind 0.0.0.0.

Simple system monitoring

Keeping track of processes is easier

Executing the Termux Battery Status command

For this quick little experiment, I used the Termux API, which I had already installed and played around with to check out various phone functions from the command line. I liked the idea of having a script automatically alert me to battery status, so I set up one that uses thetermux-battery-statuscommand as a subprocess in Python. I use the Adaptive Battery setting and like to heavily monitor my charging, discharging, and usage.

In my script file, I specified exactly how I wanted the data to be output using the print() command for each parameter, which were pretty basic:

Advertisement
Advertisement
  • Battery level

  • Status

  • Temperature

After running the script using python status.py, I received a very quick bit of info about the battery. Pretty cool. I like this script because I can check vital information without the need to open a separate app. I plan to set up similar scripts for other diagnostics soon.


Android sometimes feels like a gated fortress, but Python and Termux make it more accessible

A silly python script made in nano

The first time I loaded up Python in the terminal, I had it printing Frank Zappa lyrics. Since I've been learning the programming language this year, I've had a fantastic opportunity to expand the scope of what I can do, and I look forward to trying out other scripts, like setting up automated downloads.

These projects have all been helpful and fun experiments. Python just makes my home lab hobby much more fun, and I can't wait to see what I can do in the future as I learn more, expand my knowledge, and come up with the next wacky "because I can" project to do on my phone.

Advertisement
Advertisement
Mobilize your Website
View Site in Mobile | Classic
Share by: