Category: Projects

https://cdn3d.iconscout.com/3d/premium/thumb/project-task-management-3d-illustration-download-in-png-blend-fbx-gltf-file-formats–development-checklist-list-design-pack-business-illustrations-4496029.png

  • Pet Adoption Platform

    Project Structure

    pet_adoption/
    │
    ├── app.py                  # Main application file
    ├── templates/              # HTML templates
    │   ├── index.html
    │   ├── add_pet.html
    │   ├── pets.html
    ├── static/                 # Static files (CSS, JS)
    │   ├── style.css
    └── pets.db                 # SQLite database
    

    1. Setting Up the Backend with Flask

    First, install Flask:

    pip install Flask
    

    app.py

    from flask import Flask, render_template, request, redirect, url_for
    import sqlite3
    
    app = Flask(__name__)
    
    # Database setup
    def init_db():
    
    conn = sqlite3.connect('pets.db')
    cursor = conn.cursor()
    cursor.execute('''
        CREATE TABLE IF NOT EXISTS pets (
            id INTEGER PRIMARY KEY,
            name TEXT NOT NULL,
            type TEXT NOT NULL,
            age INTEGER NOT NULL,
            description TEXT NOT NULL
        )
    ''')
    conn.commit()
    conn.close()
    init_db() @app.route('/') def index():
    return render_template('index.html')
    @app.route('/pets') def pets():
    conn = sqlite3.connect('pets.db')
    cursor = conn.cursor()
    cursor.execute('SELECT * FROM pets')
    pets = cursor.fetchall()
    conn.close()
    return render_template('pets.html', pets=pets)
    @app.route('/add_pet', methods=['GET', 'POST']) def add_pet():
    if request.method == 'POST':
        name = request.form['name']
        pet_type = request.form['type']
        age = request.form['age']
        description = request.form['description']
        
        conn = sqlite3.connect('pets.db')
        cursor = conn.cursor()
        cursor.execute('INSERT INTO pets (name, type, age, description) VALUES (?, ?, ?, ?)', 
                       (name, pet_type, age, description))
        conn.commit()
        conn.close()
        return redirect(url_for('pets'))
    
    return render_template('add_pet.html')
    if __name__ == '__main__':
    app.run(debug=True)

    2. Creating HTML Templates

    templates/index.html

    <!DOCTYPE html>
    <html lang="en">
    <head>
    
    &lt;meta charset="UTF-8">
    &lt;meta name="viewport" content="width=device-width, initial-scale=1.0">
    &lt;link rel="stylesheet" href="{{ url_for('static', filename='style.css') }}">
    &lt;title>Pet Adoption Platform&lt;/title>
    </head> <body>
    &lt;h1>Welcome to the Pet Adoption Platform&lt;/h1>
    &lt;a href="{{ url_for('pets') }}">View Pets&lt;/a>
    &lt;a href="{{ url_for('add_pet') }}">Add a Pet&lt;/a>
    </body> </html>

    templates/pets.html

    <!DOCTYPE html>
    <html lang="en">
    <head>
    
    &lt;meta charset="UTF-8">
    &lt;meta name="viewport" content="width=device-width, initial-scale=1.0">
    &lt;link rel="stylesheet" href="{{ url_for('static', filename='style.css') }}">
    &lt;title>Available Pets&lt;/title>
    </head> <body>
    &lt;h1>Available Pets for Adoption&lt;/h1>
    &lt;ul>
        {% for pet in pets %}
            &lt;li>
                &lt;strong>{{ pet&#91;1] }}&lt;/strong> ({{ pet&#91;2] }}), Age: {{ pet&#91;3] }} - {{ pet&#91;4] }}
            &lt;/li>
        {% endfor %}
    &lt;/ul>
    &lt;a href="{{ url_for('index') }}">Home&lt;/a>
    </body> </html>

    templates/add_pet.html

    <!DOCTYPE html>
    <html lang="en">
    <head>
    
    &lt;meta charset="UTF-8">
    &lt;meta name="viewport" content="width=device-width, initial-scale=1.0">
    &lt;link rel="stylesheet" href="{{ url_for('static', filename='style.css') }}">
    &lt;title>Add a Pet&lt;/title>
    </head> <body>
    &lt;h1>Add a New Pet&lt;/h1>
    &lt;form action="{{ url_for('add_pet') }}" method="post">
        &lt;label>Name: &lt;input type="text" name="name" required>&lt;/label>&lt;br>
        &lt;label>Type: &lt;input type="text" name="type" required>&lt;/label>&lt;br>
        &lt;label>Age: &lt;input type="number" name="age" required>&lt;/label>&lt;br>
        &lt;label>Description: &lt;textarea name="description" required>&lt;/textarea>&lt;/label>&lt;br>
        &lt;button type="submit">Add Pet&lt;/button>
    &lt;/form>
    &lt;a href="{{ url_for('index') }}">Home&lt;/a>
    </body> </html>

    3. Adding Some Basic CSS

    static/style.css

    body {
    
    font-family: Arial, sans-serif;
    margin: 20px;
    } h1 {
    color: #333;
    } a {
    display: inline-block;
    margin: 10px 0;
    }

    4. Running the Application

    1. Save the files in the appropriate directories.
    2. Run the Flask app:bashCopy codepython app.py
    3. Open your web browser and go to http://127.0.0.1:5000/.
  • Front End (HTML/CSS/JavaScript)

    index.html

    <!DOCTYPE html>
    <html lang="en">
    <head>
    
    &lt;meta charset="UTF-8">
    &lt;meta name="viewport" content="width=device-width, initial-scale=1.0">
    &lt;title>Local Business Directory&lt;/title>
    &lt;link rel="stylesheet" href="styles.css">
    </head> <body>
    &lt;div class="container">
        &lt;h1>Local Business Directory&lt;/h1>
        &lt;form id="business-form">
            &lt;input type="text" id="name" placeholder="Business Name" required>
            &lt;input type="text" id="address" placeholder="Business Address" required>
            &lt;button type="submit">Add Business&lt;/button>
        &lt;/form>
        &lt;div id="business-list">&lt;/div>
    &lt;/div>
    &lt;script src="script.js">&lt;/script>
    </body> </html>

    styles.css

    body {
    
    font-family: Arial, sans-serif;
    background-color: #f4f4f4;
    padding: 20px;
    } .container {
    max-width: 600px;
    margin: auto;
    background: white;
    padding: 20px;
    border-radius: 5px;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
    } h1 {
    text-align: center;
    } form {
    margin-bottom: 20px;
    } input {
    width: 48%;
    padding: 10px;
    margin-right: 2%;
    } button {
    padding: 10px;
    background-color: #007bff;
    color: white;
    border: none;
    cursor: pointer;
    } button:hover {
    background-color: #0056b3;
    } .business-item {
    padding: 10px;
    border-bottom: 1px solid #ddd;
    }

    script.js

    document.getElementById('business-form').addEventListener('submit', function(event) {
    
    event.preventDefault();
    const name = document.getElementById('name').value;
    const address = document.getElementById('address').value;
    fetch('/api/businesses', {
        method: 'POST',
        headers: {
            'Content-Type': 'application/json',
        },
        body: JSON.stringify({ name, address }),
    })
    .then(response => response.json())
    .then(data => {
        document.getElementById('name').value = '';
        document.getElementById('address').value = '';
        loadBusinesses();
    })
    .catch(error => console.error('Error:', error));
    }); function loadBusinesses() {
    fetch('/api/businesses')
        .then(response => response.json())
        .then(data => {
            const businessList = document.getElementById('business-list');
            businessList.innerHTML = '';
            data.forEach(business => {
                const div = document.createElement('div');
                div.className = 'business-item';
                div.textContent = ${business.name} - ${business.address};
                businessList.appendChild(div);
            });
        });
    } loadBusinesses();

    Back End (Node.js/Express)

    Setup

    1. Create a directory for your project and navigate into it.
    2. Initialize a Node.js project:bashCopy codenpm init -y
    3. Install dependencies:bashCopy codenpm install express body-parser cors

    server.js

    const express = require('express');
    const bodyParser = require('body-parser');
    const cors = require('cors');
    
    const app = express();
    const PORT = process.env.PORT || 3000;
    
    app.use(cors());
    app.use(bodyParser.json());
    
    let businesses = [];
    
    // Get all businesses
    app.get('/api/businesses', (req, res) => {
    
    res.json(businesses);
    }); // Add a new business app.post('/api/businesses', (req, res) => {
    const { name, address } = req.body;
    if (name &amp;&amp; address) {
        const newBusiness = { name, address };
        businesses.push(newBusiness);
        res.status(201).json(newBusiness);
    } else {
        res.status(400).json({ message: 'Name and address are required' });
    }
    }); // Start server app.listen(PORT, () => {
    console.log(Server is running on http://localhost:${PORT});
    });

    Running the Application

    1. Start the server:
    node server.js
    1. Open index.html in a web browser to see your local business directory.
  • Custom CRM System

    Step 1: Set Up the Environment

    1. Install Flask: You can install Flask and other dependencies using pip. Create a virtual environment first for better management.
    mkdir custom_crm cd custom_crm python -m venv venv source venv/bin/activate # On Windows use venv\Scripts\activate pip install Flask Flask-SQLAlchemy
    1. Project Structure: Your project structure should look something like this:
    custom_crm/ ├── app.py ├── models.py ├── templates/ │ ├── index.html │ ├── add_customer.html └── venv/

    Step 2: Create the Models

    In models.py, define the database models. For simplicity, we’ll create a Customer model.

    pythonCopy code# models.py
    from flask_sqlalchemy import SQLAlchemy
    
    db = SQLAlchemy()
    
    class Customer(db.Model):
    
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(100), nullable=False)
    email = db.Column(db.String(120), unique=True, nullable=False)
    phone = db.Column(db.String(15))
    notes = db.Column(db.Text)
    def __repr__(self):
        return f'&lt;Customer {self.name}&gt;'

    Step 3: Create the Flask Application

    In app.py, set up the Flask app and routes.

    # app.py
    from flask import Flask, render_template, request, redirect, url_for
    from models import db, Customer
    
    app = Flask(__name__)
    app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///crm.db'
    app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
    db.init_app(app)
    
    with app.app_context():
    
    db.create_all()
    @app.route('/') def index():
    customers = Customer.query.all()
    return render_template('index.html', customers=customers)
    @app.route('/add', methods=['GET', 'POST']) def add_customer():
    if request.method == 'POST':
        name = request.form&#91;'name']
        email = request.form&#91;'email']
        phone = request.form&#91;'phone']
        notes = request.form&#91;'notes']
        new_customer = Customer(name=name, email=email, phone=phone, notes=notes)
        db.session.add(new_customer)
        db.session.commit()
        return redirect(url_for('index'))
    return render_template('add_customer.html')
    if __name__ == '__main__':
    app.run(debug=True)

    Step 4: Create the HTML Templates

    Create a simple HTML template for the customer list and the form to add new customers.

    templates/index.html:

    <!DOCTYPE html>
    <html>
    <head>
    
    &lt;title>CRM System&lt;/title>
    </head> <body>
    &lt;h1>Customer List&lt;/h1>
    &lt;a href="/add">Add Customer&lt;/a>
    &lt;ul>
        {% for customer in customers %}
            &lt;li>{{ customer.name }} - {{ customer.email }}&lt;/li>
        {% endfor %}
    &lt;/ul>
    </body> </html>

    templates/add_customer.html:

    <!DOCTYPE html>
    <html>
    <head>
    
    &lt;title>Add Customer&lt;/title>
    </head> <body>
    &lt;h1>Add New Customer&lt;/h1>
    &lt;form method="POST">
        Name: &lt;input type="text" name="name" required>&lt;br>
        Email: &lt;input type="email" name="email" required>&lt;br>
        Phone: &lt;input type="text" name="phone">&lt;br>
        Notes: &lt;textarea name="notes">&lt;/textarea>&lt;br>
        &lt;input type="submit" value="Add Customer">
    &lt;/form>
    </body> </html>

    Step 5: Run the Application

    1. Initialize the Database: If you haven’t created the database yet, run the application once to initialize it.
    2. Run the Flask App:bashCopy codepython app.py
    3. Access the CRM: Open your browser and go to http://127.0.0.1:5000/ to see your CRM in action!

  • Book Review Site

    Basic Structure

    1. HTML: Create a structure for your book reviews.
    2. CSS: Style the site to make it visually appealing.
    3. JavaScript: Add interactivity, such as adding and displaying reviews.

    Step 1: HTML

    <!DOCTYPE html>
    <html lang="en">
    <head>
    
    &lt;meta charset="UTF-8">
    &lt;meta name="viewport" content="width=device-width, initial-scale=1.0">
    &lt;title>Book Review Site&lt;/title>
    &lt;link rel="stylesheet" href="styles.css">
    </head> <body>
    &lt;div class="container">
        &lt;h1>Book Review Site&lt;/h1>
        &lt;form id="reviewForm">
            &lt;input type="text" id="bookTitle" placeholder="Book Title" required>
            &lt;textarea id="bookReview" placeholder="Write your review here..." required>&lt;/textarea>
            &lt;button type="submit">Submit Review&lt;/button>
        &lt;/form>
        &lt;div id="reviewsContainer">
            &lt;h2>Reviews:&lt;/h2>
            &lt;ul id="reviewsList">&lt;/ul>
        &lt;/div>
    &lt;/div>
    &lt;script src="script.js">&lt;/script>
    </body> </html>

    Step 2: CSS

    Create a file named styles.css to style your site.

    body {
    
    font-family: Arial, sans-serif;
    background-color: #f4f4f4;
    margin: 0;
    padding: 20px;
    } .container {
    max-width: 600px;
    margin: auto;
    background: white;
    padding: 20px;
    border-radius: 5px;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
    } h1, h2 {
    color: #333;
    } form {
    margin-bottom: 20px;
    } input[type="text"], textarea {
    width: 100%;
    padding: 10px;
    margin: 5px 0;
    border: 1px solid #ccc;
    border-radius: 4px;
    } button {
    background-color: #28a745;
    color: white;
    padding: 10px 15px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    } button:hover {
    background-color: #218838;
    } #reviewsList {
    list-style-type: none;
    padding: 0;
    } .review {
    background: #f9f9f9;
    padding: 10px;
    margin: 5px 0;
    border-radius: 4px;
    }

    Step 3: JavaScript

    Create a file named script.js to handle the review submissions and display.

    document.getElementById('reviewForm').addEventListener('submit', function(event) {
    
    event.preventDefault();
    const bookTitle = document.getElementById('bookTitle').value;
    const bookReview = document.getElementById('bookReview').value;
    const reviewList = document.getElementById('reviewsList');
    const reviewItem = document.createElement('li');
    reviewItem.classList.add('review');
    reviewItem.innerHTML = &amp;lt;strong&gt;${bookTitle}&amp;lt;/strong&gt;&amp;lt;p&gt;${bookReview}&amp;lt;/p&gt;;
    reviewList.appendChild(reviewItem);
    // Clear the form
    document.getElementById('reviewForm').reset();
    });

    Putting It All Together

    1. Folder Structure:
      • Create a folder for your project.
      • Inside that folder, create three files: index.html, styles.css, and script.js.
    2. Open the HTML: Open index.html in your web browser to see your book review site in action!

    Future Enhancements

    • Backend Integration: Use a backend service to store reviews permanently.
    • User Authentication: Allow users to create accounts and save their reviews.
    • Rating System: Implement a star rating system for reviews.
    • Search Functionality: Enable searching for books and reviews.
  • Basic Virtual Classroom Structure

    HTML (index.html)

    <!DOCTYPE html>
    <html lang="en">
    <head>
    
    &lt;meta charset="UTF-8">
    &lt;meta name="viewport" content="width=device-width, initial-scale=1.0">
    &lt;title>Virtual Classroom&lt;/title>
    &lt;link rel="stylesheet" href="styles.css">
    </head> <body>
    &lt;div class="container">
        &lt;header>
            &lt;h1>Virtual Classroom&lt;/h1>
        &lt;/header>
        &lt;main>
            &lt;div class="chat">
                &lt;h2>Chat&lt;/h2>
                &lt;div id="messages">&lt;/div>
                &lt;input type="text" id="messageInput" placeholder="Type your message...">
                &lt;button onclick="sendMessage()">Send&lt;/button>
            &lt;/div>
            &lt;div class="participants">
                &lt;h2>Participants&lt;/h2>
                &lt;ul id="participantList">&lt;/ul>
            &lt;/div>
            &lt;div class="whiteboard">
                &lt;h2>Whiteboard&lt;/h2>
                &lt;canvas id="canvas">&lt;/canvas>
            &lt;/div>
        &lt;/main>
    &lt;/div>
    &lt;script src="script.js">&lt;/script>
    </body> </html>

    CSS (styles.css)

    body {
    
    font-family: Arial, sans-serif;
    margin: 0;
    padding: 0;
    } .container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    } header {
    background-color: #4CAF50;
    color: white;
    padding: 1rem;
    text-align: center;
    } main {
    display: flex;
    flex: 1;
    padding: 1rem;
    } .chat, .participants, .whiteboard {
    border: 1px solid #ccc;
    padding: 1rem;
    margin: 0 1rem;
    flex: 1;
    } #canvas {
    border: 1px solid #000;
    width: 100%;
    height: 300px;
    }

    JavaScript (script.js)

    const messagesDiv = document.getElementById('messages');
    const messageInput = document.getElementById('messageInput');
    const participantList = document.getElementById('participantList');
    const canvas = document.getElementById('canvas');
    const ctx = canvas.getContext('2d');
    
    let participants = ['Alice', 'Bob', 'Charlie'];
    
    // Function to display messages
    function sendMessage() {
    
    const message = messageInput.value;
    if (message) {
        const messageElement = document.createElement('div');
        messageElement.textContent = message;
        messagesDiv.appendChild(messageElement);
        messageInput.value = '';
    }
    } // Function to update participant list function updateParticipants() {
    participantList.innerHTML = '';
    participants.forEach(participant => {
        const li = document.createElement('li');
        li.textContent = participant;
        participantList.appendChild(li);
    });
    } // Initial population of participants updateParticipants(); // Basic whiteboard functionality let painting = false; canvas.addEventListener('mousedown', () => {
    painting = true;
    ctx.beginPath();
    }); canvas.addEventListener('mouseup', () => {
    painting = false;
    ctx.closePath();
    }); canvas.addEventListener('mousemove', (event) => {
    if (!painting) return;
    ctx.lineWidth = 5;
    ctx.lineCap = 'round';
    ctx.strokeStyle = 'black';
    ctx.lineTo(event.clientX - canvas.offsetLeft, event.clientY - canvas.offsetTop);
    ctx.stroke();
    ctx.beginPath();
    ctx.moveTo(event.clientX - canvas.offsetLeft, event.clientY - canvas.offsetTop);
    }); // Call this to add new participants (for demonstration) setTimeout(() => {
    participants.push('Diana');
    updateParticipants();
    }, 5000);

    Explanation

    1. HTML Structure: This sets up the layout for the classroom, including sections for chat, participants, and a whiteboard.
    2. CSS Styling: Basic styling to make the classroom visually appealing and organized.
    3. JavaScript Functionality:
      • The sendMessage function allows users to type and send messages to the chat area.
      • The updateParticipants function manages the list of participants.
      • Basic drawing functionality on the whiteboard using the HTML <canvas> element.

    How to Run

    1. Create three files: index.html, styles.css, and script.js.
    2. Copy the respective code into each file.
    3. Open index.html in your web browser to see the virtual classroom in action.
  • Health Tracker

    Simple Health Tracker in Python

    pythonCopy codeimport json
    from datetime import datetime
    
    class HealthTracker:
    
    def __init__(self):
        self.data = {
            'exercises': &#91;],
            'meals': &#91;],
            'weights': &#91;]
        }
        self.load_data()
    def load_data(self):
        try:
            with open('health_data.json', 'r') as f:
                self.data = json.load(f)
        except FileNotFoundError:
            self.data = {'exercises': &#91;], 'meals': &#91;], 'weights': &#91;]}
    def save_data(self):
        with open('health_data.json', 'w') as f:
            json.dump(self.data, f, indent=4)
    def add_exercise(self, name, duration, calories_burned):
        exercise = {
            'date': str(datetime.now().date()),
            'name': name,
            'duration': duration,
            'calories_burned': calories_burned
        }
        self.data&#91;'exercises'].append(exercise)
        self.save_data()
        print(f"Added exercise: {exercise}")
    def add_meal(self, name, calories):
        meal = {
            'date': str(datetime.now().date()),
            'name': name,
            'calories': calories
        }
        self.data&#91;'meals'].append(meal)
        self.save_data()
        print(f"Added meal: {meal}")
    def add_weight(self, weight):
        weight_record = {
            'date': str(datetime.now().date()),
            'weight': weight
        }
        self.data&#91;'weights'].append(weight_record)
        self.save_data()
        print(f"Added weight: {weight_record}")
    def show_summary(self):
        print("\n--- Health Tracker Summary ---")
        print("\nExercises:")
        for exercise in self.data&#91;'exercises']:
            print(exercise)
        print("\nMeals:")
        for meal in self.data&#91;'meals']:
            print(meal)
        print("\nWeights:")
        for weight in self.data&#91;'weights']:
            print(weight)
    if __name__ == "__main__":
    tracker = HealthTracker()
    
    while True:
        print("\n1. Add Exercise")
        print("2. Add Meal")
        print("3. Add Weight")
        print("4. Show Summary")
        print("5. Exit")
        choice = input("Choose an option: ")
        if choice == '1':
            name = input("Enter exercise name: ")
            duration = input("Enter duration (in minutes): ")
            calories_burned = input("Enter calories burned: ")
            tracker.add_exercise(name, duration, calories_burned)
        
        elif choice == '2':
            name = input("Enter meal name: ")
            calories = input("Enter calories: ")
            tracker.add_meal(name, calories)
        
        elif choice == '3':
            weight = input("Enter your weight: ")
            tracker.add_weight(weight)
        
        elif choice == '4':
            tracker.show_summary()
        
        elif choice == '5':
            break
        
        else:
            print("Invalid option. Please try again.")

    How to Use This Tracker

    1. Run the Script: Save the script as health_tracker.py and run it with Python.
    2. Menu Options: You’ll see a menu to add exercises, meals, weights, or view the summary.
    3. Data Storage: The tracker saves data in a health_data.json file in the same directory, so it persists between runs.

    Extensions and Improvements

    • Data Visualization: You can use libraries like matplotlib or seaborn to create graphs of your progress over time.
    • User Interface: Consider creating a GUI with libraries like tkinter for a more user-friendly experience.
    • Health Metrics: Add more health metrics (like sleep hours, blood pressure) to track.
    • Reminders: Implement reminders for activities or meal logging.
  • Inventory Management System

    Basic Inventory Management System in Python

    class InventoryManagementSystem:
    
    def __init__(self):
        self.inventory = {}
    def add_item(self, item_name, quantity, price):
        if item_name in self.inventory:
            self.inventory&#91;item_name]&#91;'quantity'] += quantity
        else:
            self.inventory&#91;item_name] = {'quantity': quantity, 'price': price}
        print(f"Added {quantity} of {item_name}.")
    def update_item(self, item_name, quantity=None, price=None):
        if item_name in self.inventory:
            if quantity is not None:
                self.inventory&#91;item_name]&#91;'quantity'] = quantity
            if price is not None:
                self.inventory&#91;item_name]&#91;'price'] = price
            print(f"Updated {item_name}.")
        else:
            print(f"{item_name} not found in inventory.")
    def delete_item(self, item_name):
        if item_name in self.inventory:
            del self.inventory&#91;item_name]
            print(f"Deleted {item_name} from inventory.")
        else:
            print(f"{item_name} not found in inventory.")
    def view_inventory(self):
        if not self.inventory:
            print("Inventory is empty.")
            return
        for item, details in self.inventory.items():
            print(f"Item: {item}, Quantity: {details&#91;'quantity']}, Price: ${details&#91;'price']:.2f}")
    def search_item(self, item_name):
        if item_name in self.inventory:
            details = self.inventory&#91;item_name]
            print(f"Found {item_name}: Quantity: {details&#91;'quantity']}, Price: ${details&#91;'price']:.2f}")
        else:
            print(f"{item_name} not found in inventory.")
    def main():
    ims = InventoryManagementSystem()
    
    while True:
        print("\nInventory Management System")
        print("1. Add Item")
        print("2. Update Item")
        print("3. Delete Item")
        print("4. View Inventory")
        print("5. Search Item")
        print("6. Exit")
        choice = input("Choose an option: ")
        if choice == '1':
            name = input("Enter item name: ")
            qty = int(input("Enter quantity: "))
            price = float(input("Enter price: "))
            ims.add_item(name, qty, price)
        elif choice == '2':
            name = input("Enter item name to update: ")
            qty = input("Enter new quantity (leave blank to keep current): ")
            price = input("Enter new price (leave blank to keep current): ")
            qty = int(qty) if qty else None
            price = float(price) if price else None
            ims.update_item(name, qty, price)
        elif choice == '3':
            name = input("Enter item name to delete: ")
            ims.delete_item(name)
        elif choice == '4':
            ims.view_inventory()
        elif choice == '5':
            name = input("Enter item name to search: ")
            ims.search_item(name)
        elif choice == '6':
            print("Exiting the Inventory Management System.")
            break
        else:
            print("Invalid choice. Please try again.")
    if __name__ == "__main__":
    main()

    Features of the System

    1. Add Item: Allows adding new items to the inventory.
    2. Update Item: Allows updating the quantity and/or price of existing items.
    3. Delete Item: Removes items from the inventory.
    4. View Inventory: Displays all items with their quantities and prices.
    5. Search Item: Searches for a specific item in the inventory.

    How to Run the Code

    1. Copy the code into a Python file, e.g., inventory_management.py.
    2. Run the file using Python: python inventory_management.py.
    3. Follow the on-screen menu to interact with the system.
  • Online Forum or Community Board

    Step 1: Setting Up the Project

    1. Create a project directory:
    mkdir simple-forum cd simple-forum
    1. Initialize a Node.js project:bashCopy codenpm init -y
    2. Install necessary packages:
    npm install express body-parser cors

    Step 2: Backend Code (Node.js with Express)

    Create a file named server.js in your project directory:

    javascriptCopy codeconst express = require('express');
    const bodyParser = require('body-parser');
    const cors = require('cors');
    
    const app = express();
    const PORT = 3000;
    
    app.use(cors());
    app.use(bodyParser.json());
    
    let posts = [];
    
    // Get all posts
    app.get('/api/posts', (req, res) => {
    
    res.json(posts);
    }); // Create a new post app.post('/api/posts', (req, res) => {
    const { title, content } = req.body;
    const newPost = { id: posts.length + 1, title, content };
    posts.push(newPost);
    res.status(201).json(newPost);
    }); app.listen(PORT, () => {
    console.log(Server is running on http://localhost:${PORT});
    });

    Step 3: Frontend Code (HTML, CSS, and JavaScript)

    Create an index.html file in the project directory:

    <!DOCTYPE html>
    <html lang="en">
    <head>
    
    &lt;meta charset="UTF-8">
    &lt;meta name="viewport" content="width=device-width, initial-scale=1.0">
    &lt;title>Simple Forum&lt;/title>
    &lt;style>
        body {
            font-family: Arial, sans-serif;
            margin: 20px;
        }
        h1 {
            text-align: center;
        }
        #postForm {
            margin-bottom: 20px;
        }
        .post {
            border: 1px solid #ccc;
            padding: 10px;
            margin-bottom: 10px;
        }
    &lt;/style>
    </head> <body> <h1>Simple Forum</h1> <div id="postForm">
    &lt;input type="text" id="title" placeholder="Post Title" required>
    &lt;textarea id="content" placeholder="Post Content" required>&lt;/textarea>
    &lt;button onclick="submitPost()">Submit&lt;/button>
    </div> <div id="posts"></div> <script>
    async function fetchPosts() {
        const response = await fetch('http://localhost:3000/api/posts');
        const posts = await response.json();
        displayPosts(posts);
    }
    function displayPosts(posts) {
        const postsDiv = document.getElementById('posts');
        postsDiv.innerHTML = '';
        posts.forEach(post => {
            const postDiv = document.createElement('div');
            postDiv.classList.add('post');
            postDiv.innerHTML = &amp;lt;h3&gt;${post.title}&amp;lt;/h3&gt;&amp;lt;p&gt;${post.content}&amp;lt;/p&gt;;
            postsDiv.appendChild(postDiv);
        });
    }
    async function submitPost() {
        const title = document.getElementById('title').value;
        const content = document.getElementById('content').value;
        const response = await fetch('http://localhost:3000/api/posts', {
            method: 'POST',
            headers: {
                'Content-Type': 'application/json'
            },
            body: JSON.stringify({ title, content })
        });
        if (response.ok) {
            document.getElementById('title').value = '';
            document.getElementById('content').value = '';
            fetchPosts();
        }
    }
    fetchPosts();
    </script> </body> </html>

    Step 4: Running the Application

    1. Start the backend server:
    node server.js
    1. Open index.html in your web browser.
  • Survey and Polling Application

    Project Structure

    survey_app/
    │
    ├── app.py               # Main application file
    ├── database.db          # SQLite database file
    ├── templates/           # Folder for HTML templates
    │   ├── index.html       # Main survey form
    │   └── results.html     # Results display page
    └── static/              # Folder for static files (CSS, JS)
    
    └── styles.css       # CSS styles

    Step 1: Set Up Flask

    First, make sure you have Flask installed. You can do this via pip:

    pip install Flask
    

    Step 2: Create the Main Application (app.py)

    Here’s a basic implementation of the Flask application:

    from flask import Flask, render_template, request, redirect
    import sqlite3
    
    app = Flask(__name__)
    
    # Database setup
    def init_db():
    
    with sqlite3.connect('database.db') as conn:
        cursor = conn.cursor()
        cursor.execute('''
            CREATE TABLE IF NOT EXISTS survey (
                id INTEGER PRIMARY KEY AUTOINCREMENT,
                question TEXT,
                answer TEXT
            )
        ''')
        conn.commit()
    init_db() @app.route('/') def index():
    return render_template('index.html')
    @app.route('/submit', methods=['POST']) def submit():
    question = request.form.get('question')
    answer = request.form.get('answer')
    with sqlite3.connect('database.db') as conn:
        cursor = conn.cursor()
        cursor.execute('INSERT INTO survey (question, answer) VALUES (?, ?)', (question, answer))
        conn.commit()
    return redirect('/results')
    @app.route('/results') def results():
    with sqlite3.connect('database.db') as conn:
        cursor = conn.cursor()
        cursor.execute('SELECT question, answer FROM survey')
        results = cursor.fetchall()
    return render_template('results.html', results=results)
    if __name__ == '__main__':
    app.run(debug=True)

    Step 3: Create HTML Templates

    templates/index.html

    <!DOCTYPE html>
    <html lang="en">
    <head>
    
    &lt;meta charset="UTF-8">
    &lt;meta name="viewport" content="width=device-width, initial-scale=1.0">
    &lt;link rel="stylesheet" href="{{ url_for('static', filename='styles.css') }}">
    &lt;title>Survey Application&lt;/title>
    </head> <body>
    &lt;h1>Survey&lt;/h1>
    &lt;form action="/submit" method="post">
        &lt;label for="question">Question:&lt;/label>&lt;br>
        &lt;input type="text" id="question" name="question" required>&lt;br>&lt;br>
        
        &lt;label for="answer">Answer:&lt;/label>&lt;br>
        &lt;input type="text" id="answer" name="answer" required>&lt;br>&lt;br>
        
        &lt;button type="submit">Submit&lt;/button>
    &lt;/form>
    </body> </html>

    templates/results.html

    <!DOCTYPE html>
    <html lang="en">
    <head>
    
    &lt;meta charset="UTF-8">
    &lt;meta name="viewport" content="width=device-width, initial-scale=1.0">
    &lt;link rel="stylesheet" href="{{ url_for('static', filename='styles.css') }}">
    &lt;title>Survey Results&lt;/title>
    </head> <body>
    &lt;h1>Survey Results&lt;/h1>
    &lt;table>
        &lt;tr>
            &lt;th>Question&lt;/th>
            &lt;th>Answer&lt;/th>
        &lt;/tr>
        {% for question, answer in results %}
        &lt;tr>
            &lt;td>{{ question }}&lt;/td>
            &lt;td>{{ answer }}&lt;/td>
        &lt;/tr>
        {% endfor %}
    &lt;/table>
    &lt;a href="/">Back to Survey&lt;/a>
    </body> </html>

    Step 4: Add CSS (static/styles.css)

    cssCopy codebody {
    
    font-family: Arial, sans-serif;
    margin: 20px;
    } h1 {
    color: #333;
    } form {
    margin-bottom: 20px;
    } table {
    width: 100%;
    border-collapse: collapse;
    } table, th, td {
    border: 1px solid #ddd;
    } th, td {
    padding: 8px;
    text-align: left;
    }

    Step 5: Run the Application

    To run the application, navigate to the project directory in your terminal and execute:

    bashCopy codepython app.py
    

    Then open your web browser and go to http://127.0.0.1:5000.

  • Travel Planning App

    Step 1: Setting Up Your Environment

    1. Install Flask: Make sure you have Python installed. You can install Flask using pip:bashCopy codepip install Flask
    2. Create a Project Directory:bashCopy codemkdir travel_planner cd travel_planner
    3. Create Required Files:
      • app.py (Flask app)
      • templates/ (folder for HTML files)
      • static/ (folder for CSS/JS files)

    Step 2: Create the Flask App

    app.py

    pythonCopy codefrom flask import Flask, render_template, request, redirect, url_for
    
    app = Flask(__name__)
    
    # Simple in-memory storage for itineraries
    itineraries = []
    
    @app.route('/')
    def home():
    
    return render_template('index.html', itineraries=itineraries)
    @app.route('/add', methods=['POST']) def add_itinerary():
    destination = request.form.get('destination')
    date = request.form.get('date')
    activities = request.form.get('activities')
    itineraries.append({'destination': destination, 'date': date, 'activities': activities.split(',')})
    return redirect(url_for('home'))
    @app.route('/delete/<int:index>') def delete_itinerary(index):
    if 0 &lt;= index &lt; len(itineraries):
        itineraries.pop(index)
    return redirect(url_for('home'))
    if __name__ == '__main__':
    app.run(debug=True)

    Step 3: Create HTML Templates

    templates/index.html

    htmlCopy code<!DOCTYPE html>
    <html lang="en">
    <head>
    
    &lt;meta charset="UTF-8"&gt;
    &lt;meta name="viewport" content="width=device-width, initial-scale=1.0"&gt;
    &lt;link rel="stylesheet" href="{{ url_for('static', filename='styles.css') }}"&gt;
    &lt;title&gt;Travel Planner&lt;/title&gt;
    </head> <body>
    &lt;h1&gt;Travel Planner&lt;/h1&gt;
    &lt;form action="/add" method="POST"&gt;
        &lt;input type="text" name="destination" placeholder="Destination" required&gt;
        &lt;input type="date" name="date" required&gt;
        &lt;input type="text" name="activities" placeholder="Activities (comma-separated)" required&gt;
        &lt;button type="submit"&gt;Add Itinerary&lt;/button&gt;
    &lt;/form&gt;
    
    &lt;h2&gt;Your Itineraries&lt;/h2&gt;
    &lt;ul&gt;
        {% for itinerary in itineraries %}
            &lt;li&gt;
                &lt;strong&gt;{{ itinerary.destination }}&lt;/strong&gt; - {{ itinerary.date }}&lt;br&gt;
                Activities: {{ ', '.join(itinerary.activities) }} 
                &lt;a href="{{ url_for('delete_itinerary', index=loop.index0) }}"&gt;Delete&lt;/a&gt;
            &lt;/li&gt;
        {% endfor %}
    &lt;/ul&gt;
    </body> </html>

    Step 4: Add Some Styles

    static/styles.css

    cssCopy codebody {
    
    font-family: Arial, sans-serif;
    margin: 20px;
    } h1 {
    color: #333;
    } form {
    margin-bottom: 20px;
    } input {
    margin: 5px;
    }

    Step 5: Run the App

    Navigate to your project directory in the terminal and run:

    bashCopy codepython app.py
    

    Open your web browser and go to http://127.0.0.1:5000 to see your travel planning app in action!