Modern Web App using HTMX (No JavaScript Required!)

Demo :


Click Video πŸ‘‡πŸ‘‡πŸ‘‡












HTMX + PHP: Modern Web App (No JavaScript Needed!)

πŸ“‚ Folder Structure :

/modern-htmx-app │── index.html │── style.css │── script.js (Minimal) │── server.php


Code :

1️⃣ index.html (Main Web Page)

<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>HTMX Web App</title> <link rel="stylesheet" href="style.css"> <script src="https://unpkg.com/htmx.org@1.9.5"></script> </head> <body> <div class="container"> <h2>HTMX Web App - No JavaScript Required!</h2> <!-- Input Form --> <form id="dataForm" hx-post="server.php" hx-target="#response" hx-swap="innerHTML"> <input type="text" name="username" placeholder="Enter your name" required> <button type="submit">Submit</button> </form> <!-- Response Area --> <div id="response"></div> </div> </body> </html>

2️⃣ style.css (Basic Styling)

body { font-family: Arial, sans-serif; text-align: center; background: #f4f4f4; padding: 50px; } .container { max-width: 400px; margin: auto; background: white; padding: 20px; border-radius: 10px; box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.1); } input { width: 80%; padding: 10px; margin-bottom: 10px; border: 1px solid #ddd; } button { background: #28a745; color: white; border: none; padding: 10px 20px; cursor: pointer; } button:hover { background: #218838; }


3️⃣ server.php (Handles the Request)


<?php if ($_SERVER["REQUEST_METHOD"] == "POST") { $name = htmlspecialchars($_POST["username"]); echo "<h3>Welcome, $name!</h3>"; } ?>


4️⃣ script.js (Optional - Minimal JavaScript for Enhancements)


document.addEventListener("DOMContentLoaded", function () { console.log("HTMX Web App Loaded!"); });

Comments

Popular posts from this blog

πŸš€ Simple Login & Registration System in Python Tkinter πŸ“±

πŸš€ Create a Python Screen Recorder with Audio (Complete Code)

πŸ“‘ Fuzzu Packet Sniffer – Python GUI for Real-Time IP Monitoring | Tkinter + Scapy