Building a Lightweight EXFO Tester Admin Panel with FastAPI and Alpine.js
In this post, I’ll walk you through how to build a lightweight web application that integrates with EXFO tester APIs, allows for user authentication, and fetches test results using FastAPI and Alpine.js.
Why FastAPI + Alpine.js?
- FastAPI is a modern, async-ready web framework perfect for building APIs and backend systems.
- Alpine.js is a minimal JavaScript framework that allows you to add interactivity without needing a heavy frontend like React or Vue.
- Together, they create a clean, fast, and powerful stack ideal for internal admin panels or embedded control apps.
Key Features
- Session-based login system (username + password)
- Authentication-protected API endpoints
- A single HTML page that dynamically fetches test results after login
- EXFO integration placeholder for real test results
Tech Stack
- Backend: FastAPI
- Frontend: HTML + TailwindCSS + Alpine.js
- Auth: Session-based with cookie storage
- API: Mock EXFO test result endpoint
Basic Fiber Optic Terms
Before diving into EXFO testing, it's helpful to understand some key fiber optic terms:
- OLT (Optical Line Terminal): The central device at the telecom provider that sends data to multiple ONUs.
- ONU/ONT (Optical Network Unit/Terminal): The device at the user's location that receives data from the OLT.
- PON (Passive Optical Network): A point-to-multipoint fiber network that uses unpowered splitters.
- GPON/XGS-PON: Standards for PONs offering different speeds (GPON = 2.5 Gbps down; XGS-PON = 10 Gbps symmetrically).
- dBm: Measurement unit for optical signal power.
How to Configure an EXFO PON Tester (Basics)
1.Connect the Tester
- Plug the fiber cable from the splitter or drop cable into the EXFO tester's "ONT" port.
- Optionally connect the ONU to the tester's "PON" output port for inline testing.
2.Select PON Mode
- Choose between GPON, XGS-PON, or dual-mode depending on your deployment.
3.Power Measurement
- Start a power test to check downstream (OLT) and upstream (ONT) signal levels.
- Typical acceptable range: –8 dBm to –27 dBm.
4.Pass/Fail Results
- The tester will display whether levels are within thresholds.
- Adjust thresholds manually if needed to match your network standard.
5.Save/Export Results
- Use USB or API integration to export results to your backend or PC.
System Deployment Diagram (Mermaid.js)
graph TD
A["EXFO Tester"] --> B["FastAPI Server"]
B --> C["Session Auth API"]
B --> D["Test Results API"]
D --> E["MongoDB (optional)"]
B --> F["Static HTML + Alpine.js"]
F --> G["User Browser"]
G -->|login| C
G -->|view data| D
ONT + EXFO Tester Configuration Flow (Mermaid.js)
graph LR
Start["Start"] --> Splitter["Connect Drop Fiber to EXFO Tester (ONT Port)"]
Splitter --> InlineTest["(Optional) Connect ONU to PON Port for Inline Test"]
InlineTest --> Mode["Select PON Mode: GPON / XGS-PON"]
Mode --> PowerTest["Run Optical Power Test"]
PowerTest --> Result["Check Signal Levels: OLT RX / ONT TX"]
Result --> Decision{"Within Acceptable Range?"}
Decision -- Yes --> Save["Save / Export Result"]
Decision -- No --> Adjust["Adjust Fiber or Ports and Retest"]
Save --> Done["Done"]
Adjust --> PowerTest
EXFO Tester Physical Setup Diagram (Mermaid.js)
graph TD
A["OLT (Central Office)"] --> B["Splitter"]
B --> C["Drop Fiber"]
C --> D["EXFO Tester (ONT Port)"]
D -->|optional| E["PON Port to ONU"]
E --> F["User Premises / ONU Device"]
This diagram shows the standard setup for inline testing using an EXFO tester. The drop fiber is connected to the ONT port, and optionally, the ONU can be connected to the PON port so the tester sits inline and does not interrupt service.
graph LR
Start["Start"] --> Splitter["Connect Drop Fiber to EXFO Tester (ONT Port)"]
Splitter --> InlineTest["(Optional) Connect ONU to PON Port for Inline Test"]
InlineTest --> Mode["Select PON Mode: GPON / XGS-PON"]
Mode --> PowerTest["Run Optical Power Test"]
PowerTest --> Result["Check Signal Levels: OLT RX / ONT TX"]
Result --> Decision{"Within Acceptable Range?"}
Decision -- Yes --> Save["Save / Export Result"]
Decision -- No --> Adjust["Adjust Fiber or Ports and Retest"]
Save --> Done["Done"]
Adjust --> PowerTest
graph TD
A["EXFO Tester"] --> B["FastAPI Server"]
B --> C["Session Auth API"]
B --> D["Test Results API"]
D --> E["MongoDB (optional)"]
B --> F["Static HTML + Alpine.js"]
F --> G["User Browser"]
G -->|login| C
G -->|view data| D
1. Project Setup
Install dependencies:
pip install fastapi uvicorn python-multipart jinja2
Directory structure:
project/
├── main.py
└── templates/
└── index.html
2. FastAPI Backend Code (main.py)
from fastapi import FastAPI, Request, Form
from fastapi.responses import RedirectResponse, JSONResponse
from fastapi.templating import Jinja2Templates
from starlette.middleware.sessions import SessionMiddleware
app = FastAPI()
app.add_middleware(SessionMiddleware, secret_key="supersecret")
templates = Jinja2Templates(directory="templates")
users = {"admin": {"password": "1234"}}
fake_data = [
{"id": 1, "onu": "ONU123", "status": "PASS"},
{"id": 2, "onu": "ONU456", "status": "FAIL"},
]
def get_current_user(request: Request):
return request.session.get("user")
@app.get("/")
def index(request: Request):
user = get_current_user(request)
return templates.TemplateResponse("index.html", {"request": request, "user": user})
@app.post("/login")
def login(request: Request, username: str = Form(...), password: str = Form(...)):
if username in users and users[username]["password"] == password:
request.session["user"] = username
return RedirectResponse("/", status_code=303)
return RedirectResponse("/?error=1", status_code=303)
@app.get("/logout")
def logout(request: Request):
request.session.clear()
return RedirectResponse("/", status_code=303)
@app.get("/api/test-results")
def get_test_data(request: Request):
if not get_current_user(request):
return JSONResponse(status_code=401, content={"detail": "Unauthorized"})
return fake_data
3. HTML + Alpine.js Frontend (templates/index.html)
<!DOCTYPE html>
<html lang="en" x-data="testApp()" x-init="init()">
<head>
<script src="https://cdn.jsdelivr.net/npm/alpinejs" defer></script>
<link href="https://cdn.jsdelivr.net/npm/tailwindcss@2.2.19/dist/tailwind.min.css" rel="stylesheet">
<title>EXFO Admin Panel</title>
</head>
<body class="p-6 bg-gray-100">
<div class="max-w-xl mx-auto bg-white p-6 rounded shadow text-center">
<template x-if="!loggedIn">
<form method="POST" action="/login" class="space-y-4">
<h2 class="text-xl font-bold">Login</h2>
<input type="text" name="username" placeholder="Username" class="border p-2 w-full">
<input type="password" name="password" placeholder="Password" class="border p-2 w-full">
<button type="submit" class="bg-blue-600 text-white px-4 py-2 rounded">Login</button>
</form>
</template>
<template x-if="loggedIn">
<div>
<h2 class="text-xl font-bold mb-4">Test Results</h2>
<a href="/logout" class="text-sm text-blue-600 underline">Logout</a>
<ul class="mt-4 space-y-2 text-left">
<template x-for="item in testResults" :key="item.id">
<li class="p-2 border rounded">
<strong x-text="item.onu"></strong> - <span x-text="item.status"></span>
</li>
</template>
</ul>
</div>
</template>
</div>
<script>
function testApp() {
return {
loggedIn: {{ 'true' if user else 'false' }},
testResults: [],
async init() {
if (this.loggedIn) {
try {
const res = await fetch('/api/test-results');
if (res.ok) {
this.testResults = await res.json();
}
} catch (err) {
console.error("Error fetching test results", err);
}
}
}
}
}
</script>
</body>
</html>
4. Run It
uvicorn main:app --reload
Visit http://localhost:8000 and log in with:
- Username:
admin - Password:
1234
Conclusion
This is a great starting point for building an EXFO-integrated dashboard with:
- Lightweight UI using Tailwind + Alpine.js
- FastAPI backend with full async support
- Session-based login
- API-protected data views
You can expand this to include:
- MongoDB support
- Real EXFO tester API calls
- Role-based access control
- Export to CSV/PDF
Need help upgrading it? Drop a comment!
Get in Touch with us
Related Posts
- NVIDIA、Microsoft、OpenAI、Google、Oracle 以及 AMD:正在共同推动 AI 泡沫如何形成?
- The Real AI Bubble: How NVIDIA, Microsoft, OpenAI, Google, Oracle — and Now AMD — Shape the Future of Compute
- 深度学习在房地产开发中的应用
- Deep Learning in Property Development
- 代码修复与遗留系统维护服务 —— Simplico 助力企业保持系统稳定、安全、高效
- Code Fixing & Legacy System Maintenance — Keep Your Business Running Smoothly with Simplico
- Python 深度学习在工厂自动化中的应用:2025 全面指南
- Python Deep Learning in Factory Automation: A Complete Guide (2025)
- 工厂 / 制造业专用 Python 开发与培训服务
- Python Development & Industrial Automation Training Services
- 为什么 Python + Django 是现代电商系统的最佳技术栈(完整指南 + 定价方案)
- Why Python + Django Is the Best Tech Stack for Building Modern eCommerce Platforms (Complete Guide + Pricing Plans)
- 三十六计现代商业版:理解中国企业竞争、谈判与战略思维的终极指南
- The 36 Chinese Business Stratagems: A Modern Guide to Understanding How Chinese Companies Compete and Win
- 理解机器学习中的 Training、Validation、Testing
- Understanding Training, Validation, and Testing in Machine Learning
- 深入理解神经网络
- Understanding Neural Networks Deeply
- AI 商品真伪鉴定系统:为现代零售品牌打造的智能解决方案
- AI-Powered Product Authenticity Verification for Modern Retail Brands













