Web app dùng Flask và OpenCV để:
- Upload ảnh
- Xử lý ảnh
- Hiển thị ảnh gốc và ảnh đã xử lý
- Giao diện responsive với HTML + TailwindCSS
- Cài đặt Python 3.10
- Tạo môi trường ảo và cài đặt thư viện:
or
run.bat.\run.bat
image_app/
├── app.py # File chính chạy Flask
├── requirements.txt # Thư viện cần thiết
├── static/ # File tĩnh
│ ├── css/
│ ├── js/
│ ├── img/
├── templates/ # HTML templates
└── utils/ # Logic xử lý Python
static/js/
├── data.js # Mô tả hình ảnh
├── modal.js # Modal gallery
├── navigation.js # Responsive menu
├── api.js # Giao tiếp Flask API
├── header.js # Quản lý header
└── main.js # Khởi tạo chính
- data.js: Quản lý mô tả ảnh
- modal.js: Class
ModalGallery(show/close modal, animations) - navigation.js: Class
Navigation(toggle/close sidebar, mobile support) - api.js: Class
FlaskAPI(async API calls, error handling) - header.js: Class
HeaderComponent(scroll effects, active menu) - main.js: Entry point, debug, global config
- Tạo file JS mới trong
static/js/ - Tạo class cho tính năng
- Import vào
index.html - Khởi tạo trong
main.js
Ví dụ:
class NewFeature {
constructor() { this.init(); }
init() { /* Code */ }
}
const newFeature = new NewFeature();templates/
├── index.html
└── components/
└── header.html # Navbar + Sidebar
- header.html: Sticky navbar, responsive sidebar, nav links, logo, hamburger menu
- header.js: Class
HeaderComponent(scroll effects, active menu, toggle navbar)
{% include 'components/header.html' %}headerComponent.setActiveMenuItem('about');
headerComponent.toggleNavbar(true); // Show