Add Flask-based implementation with threading as alternative to Panel #1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Overview
This PR introduces a complete Flask-based reimplementation of PowerPi that maintains all functionality of the Panel version while utilizing a more standard web application architecture with Python threading for non-blocking sensor data collection.
Motivation
The original Panel-based implementation, while functional, has some limitations:
What's New
This PR adds a Flask version as an alternative implementation while preserving the original Panel version. Users can choose which version to use based on their needs.
Architecture Changes
Web Framework: Flask + Flask-SocketIO instead of Panel/Holoviews
Threading Model: Python threading for background tasks
Frontend: Modern HTML/CSS/JavaScript
Performance Improvements
Features Preserved
All three main features are fully implemented:
File Structure
Documentation
Added comprehensive documentation:
Usage
Installation
Running
python3 app.py # or ./run_flask.shAccessing
Navigate to
http://localhost:8080orhttp://<raspberry-pi-ip>:8080Technical Details
Threading Implementation
Background threads handle sensor data collection without blocking the main Flask application:
WebSocket Communication
Real-time updates use Socket.IO namespaces:
/data-logger: Data logging operations/live-view: Live streaming of sensor dataAPI Endpoints
GET /: Data Logger pageGET /live-view: Live View pageGET /data-explorer: Data Explorer pagePOST /api/load-csv: Load and process CSV filesGET /api/status: Application statusCompatibility
sensor.pyunchanged)Testing
All code has been validated:
Migration Path
For existing users:
pip install -r requirements-flask.txtBenefits
For Production Use:
For Development:
For Users:
Conclusion
This PR provides a production-ready Flask alternative to the Panel version, offering better performance, scalability, and maintainability while preserving all existing functionality. Users can choose the implementation that best fits their needs.
The original Panel implementation remains untouched and fully functional.
Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.