Deploying a Production-Ready Python Web Service on Radxa SBCs

Why Your IoT Project Needs a Robust Web Server

In our previous guide, we discussed how to use a Radxa SBC as a central brain for your IoT system. But how do you actually visualize that data or expose an API for your mobile apps?
Many beginners start by running a simple Python Flask or Django server directly (python app.py). While this works for testing, it is not suitable for production. It is single-threaded, lacks security, and will crash under heavy load.
At ESP32s.com, we believe in building professional-grade systems. In this tutorial, we will show you how to deploy a production-ready Python Web service on your Radxa board (whether it’s the compact ZERO 3W or the powerful ROCK 5) using the industry-standard Gunicorn + Nginx stack.

Step 1: Preparing Your Radxa Environment

Before deploying, ensure your Radxa board is running a fresh Debian or Ubuntu Linux image. Connect to your board via SSH and update the system:
bash
sudo apt update && sudo apt upgrade -y
Next, install the necessary system dependencies and Python tools. We recommend using a virtual environment to keep your project dependencies isolated:
bash
sudo apt install python3-pip python3-venv nginx -y

Step 2: Setting Up the Python Web Application

Let’s assume you have a simple Flask application (app.py) that serves sensor data from your ESP32 nodes. First, create a dedicated directory and a virtual environment:
bash
mkdir ~/iot-dashboard && cd ~/iot-dashboard
python3 -m venv venv
source venv/bin/activate
Install Flask and Gunicorn inside the virtual environment:
bash
pip install flask gunicorn
Create a basic app.py file for testing:
python
from flask import Flask
app = Flask(__name__)

@app.route('/')
def home():
    return "Radxa IoT Dashboard is Live!"

if __name__ == '__main__':
    app.run()

Step 3: Configuring Gunicorn (The WSGI Server)

Gunicorn acts as the bridge between your Python application and the web server. It handles multiple requests simultaneously, which is crucial if you have dozens of ESP32 nodes sending data.
Test Gunicorn by running:
bash
gunicorn --workers 3 --bind 127.0.0.1:8000 app:app
Note: --workers 3 spawns three worker processes. On a Radxa ZERO 3W (Quad-core), 3-4 workers are optimal. On a ROCK 5 (Octa-core), you can increase this number.

Step 4: Configuring Nginx (The Reverse Proxy)

Nginx sits in front of Gunicorn. It handles security, static files, and load balancing. Create a new Nginx configuration file:
bash
sudo nano /etc/nginx/sites-available/iot-dashboard
Paste the following configuration:
nginx
server {
    listen 80;
    server_name your_radxa_ip_address;

    location / {
        proxy_pass http://127.0.0.1:8000;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
    }
}
Enable the site and restart Nginx:
bash
sudo ln -s /etc/nginx/sites-available/iot-dashboard /etc/nginx/sites-enabled
sudo systemctl restart nginx
Now, if you visit your Radxa board’s IP address in a browser, you will see your Flask application running securely behind Nginx!

Step 5: Making It Persistent (Systemd Service)

If you reboot your Radxa board, your web service will stop. To fix this, we create a systemd service so it starts automatically on boot.
Create a service file:

bash

sudo nano /etc/systemd/system/iot-dashboard.service
Add the following configuration:

ini

[Unit]
Description=Gunicorn instance to serve IoT Dashboard
After=network.target

[Service]
User=radxa
Group=www-data
WorkingDirectory=/home/radxa/iot-dashboard
Environment="PATH=/home/radxa/iot-dashboard/venv/bin"
ExecStart=/home/radxa/iot-dashboard/venv/bin/gunicorn --workers 3 --bind unix:iot-dashboard.sock -m 007 app:app

[Install]
WantedBy=multi-user.target
Enable and start the service:
bash
sudo systemctl start iot-dashboard
sudo systemctl enable iot-dashboard

🛒 Power Your Edge Computing with ESP32s.com

Deploying a robust web service is just one part of the puzzle. You need reliable hardware to run it on.
  • For Compact Gateways: The Radxa ZERO 3W is perfect for running lightweight Flask/Nginx stacks while aggregating data from your ESP32 sensors.
  • For Heavy-Duty AI & Data Processing: If your web service needs to process video feeds or run complex AI models alongside the web server, upgrade to the Radxa ROCK 5 series.
At ESP32s.com, we provide not just the boards, but the entire ecosystem—from ESP32 sensor nodes to high-performance Radxa SBCs.
👉 [Shop Radxa SBCs & IoT Accessories Today]

======================================

About ESP32S.com

Since 2016, ESP32S.com has grown to become a complete ecosystem partner for your IoT journey. Based in Shenzhen, a global hub for electronics innovation, we have helped hundreds of developers and businesses bring their ESP32-based ideas to life. Our team is dedicated to providing exceptional support and innovative solutions to help you achieve your IoT goals.
At ESP32S.com, we master the intricacies of developing an ESP32-based product, which involves multiple stages, from concept to market launch. That’s why we now offer comprehensive solutions covering the entire product lifecycle for ESP32-based devices. Whether you need help with PCB design, prototyping, production, or even marketing and fulfillment, we have you covered.

Contact Us

Ready to take your IoT project to the next level? Contact ESP32S.com today to learn more about our comprehensive solutions for ESP32-based devices. Let us be your trusted partner in bringing your innovative ideas to life. Contact us now to get started.

Table of Contents

Related Posts
Start typing to see products you are looking for.
Shopping cart
Sign in

No account yet?

Shop
Wishlist
0 items Cart
My account
/** * salesmartly 聊天插件 */