React & Node.js Programs

🔷 1. React Counter App (Functional Component) ✅ Question: Create a counter app using functional components in React. 💻 Solution: import React, { useState } from “react”;function Counter() { const [count, setCount] = useState(0); return ( <div style={{ textAlign: “center” }}> <h2>Counter App</h2> <h3>{count}</h3> <button onClick={() => setCount(count + 1)}>Increment</button> <button onClick={() => setCount(count – …

Create and Configure a Custom 500 Error Page

🎯 Objective To create a custom 500 error page for server-side errors. ❗ What is 500 Error? 500 error occurs when: Server crashes Code error occurs Internal server issue 📄 Step 1: Create Template templates/500.html <!DOCTYPE html><html><head> <title>Server Error</title></head><body> <h1>500 Error</h1> <p>Something went wrong. Please try again later.</p></body></html> ⚙️ Step 2: Configure Settings # settings.pyDEBUG …

Create and Configure a Custom 404 Error Page

🎯 Objective To create a custom 404 error page when a user visits a non-existing URL. ❗ What is 404 Error? 404 error occurs when: Page not found Invalid URL entered 📄 Step 1: Create Template Create file: templates/404.html <!DOCTYPE html><html><head> <title>Page Not Found</title></head><body> <h1>404 Error</h1> <p>Oops! Page not found.</p> <a href=”/”>Go to Home</a></body></html> ⚙️ …

Implement CRUD Operations Using Django Class-Based Views

🎯 Objective To implement Create, Read, Update, Delete (CRUD) operations using Django Class-Based Views (CBVs) for better structure and code reusability. 📌 What are Class-Based Views? Class-Based Views (CBVs) are an alternative to function-based views. They provide: Reusable code Less duplication Built-in functionality for CRUD 📦 Step 1: Model (Student) # models.pyfrom django.db import modelsclass …

Authentication with Django – Login and Logout

📌 Introduction After user registration, the next step is authentication: login logout restricting access to certain pages Django provides built-in functions for this: authenticate() login() logout() @login_required 🎯 Program Statement 👉 Implement login, logout, and protected page using authentication. 🧠 Concept This program uses: Django authentication system session management protected routes ⚙️ Step 1: Create …

Create a User Registration Page using Django Built-in User Model

📌 Introduction Django provides a built-in User model for authentication.Using this model, we can create features like: user registration login logout password management In this program, we will create a registration page where a new user can sign up using: username email password confirm password This is a very important topic for real-world applications. 🎯 …

Create a Superuser and Perform Database Operations through Admin Panel

📌 Introduction The Django admin panel can only be accessed by authorized users. 👉 For this, we create a superuser, who has: full permissions access to admin panel ability to perform all database operations 🎯 Program Statement 👉 Create a superuser and perform database operations through admin panel. 🧠 Concept This program involves: creating superuser …

Customize Admin Interface

📌 Introduction By default, Django admin shows very basic data. But in real applications, we need: multiple columns search functionality filters for quick navigation 👉 Django provides customization options in admin.py. 🎯 Program Statement 👉 Customize admin interface using list_display, search_fields, and filters. 🧠 Concept This program uses: ModelAdmin class list_display → show columns search_fields …

Register a Model in Django Admin and Display Records

📌 Introduction Django provides a powerful Admin Interface that allows you to: view records add new data update records delete records 👉 But for this, the model must be registered in admin.py. 🎯 Program Statement 👉 Register a model in Django admin and display records. 🧠 Concept This program uses: models.py → database structure admin.py …