|
13 | 13 | }
|
14 | 14 |
|
15 | 15 | body {
|
16 |
| - background-color: #f4f4f4; |
| 16 | + background-color: #121212; |
| 17 | + color: #e0e0e0; |
| 18 | + display: flex; |
| 19 | + justify-content: center; |
| 20 | + align-items: center; |
| 21 | + min-height: 100vh; |
| 22 | + overflow: hidden; |
17 | 23 | }
|
18 | 24 |
|
19 | 25 | .container {
|
20 | 26 | max-width: 800px;
|
21 |
| - margin: 50px auto; |
22 |
| - padding: 20px; |
23 |
| - background-color: #fff; |
24 |
| - box-shadow: 0 0 15px rgba(0, 0, 0, 0.1); |
25 |
| - border-radius: 5px; |
26 |
| - transition: box-shadow 0.3s ease; |
| 27 | + width: 100%; |
| 28 | + margin: 20px auto; |
| 29 | + padding: 30px; |
| 30 | + background-colP0+r\P0+r\or: #1e1e1e; |
| 31 | + box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2); |
| 32 | + border-radius: 10px; |
| 33 | + transition: box-shadow 0.3s ease, transform 0.3s ease; |
27 | 34 | }
|
28 | 35 |
|
29 | 36 | .container:hover {
|
30 |
| - box-shadow: 0 0 20px rgba(0, 0, 0, 0.15); |
| 37 | + box-shadow: 0 8px 16px rgba(0, 0, 0, 0.3); |
| 38 | + transform: translateY(-5px); |
31 | 39 | }
|
32 | 40 |
|
33 | 41 | h1 {
|
34 |
| - color: #007BFF; |
| 42 | + color: #ff9800; |
35 | 43 | margin-bottom: 20px;
|
36 |
| - border-bottom: 2px solid #f0f0f0; |
| 44 | + border-bottom: 2px solid #333; |
37 | 45 | padding-bottom: 10px;
|
| 46 | + text-align: center; |
| 47 | + font-size: 1.8rem; |
38 | 48 | }
|
39 | 49 |
|
40 | 50 | p {
|
41 |
| - color: #666; |
42 |
| - margin-bottom: 10px; |
| 51 | + color: #ccc; |
| 52 | + margin-bottom: 15px; |
| 53 | + font-size: 1rem; |
43 | 54 | }
|
44 | 55 |
|
45 | 56 | form {
|
46 | 57 | display: flex;
|
47 | 58 | flex-direction: column;
|
48 |
| - gap: 10px; |
| 59 | + gap: 15px; |
49 | 60 | }
|
50 | 61 |
|
51 | 62 | input[type="text"] {
|
52 |
| - padding: 10px; |
53 |
| - border: 1px solid #ccc; |
| 63 | + padding: 12px; |
| 64 | + border: 1px solid #333; |
| 65 | + background-color: #2c2c2c; |
| 66 | + color: #fff; |
54 | 67 | border-radius: 4px;
|
55 | 68 | font-size: 16px;
|
56 |
| - transition: border-color 0.3s ease; |
| 69 | + transition: border-color 0.3s ease, box-shadow 0.3s ease; |
57 | 70 | }
|
58 | 71 |
|
59 | 72 | input[type="text"]:hover, input[type="text"]:focus {
|
60 |
| - border-color: #007BFF; |
| 73 | + border-color: #ff9800; |
| 74 | + box-shadow: 0 0 8px rgba(255, 152, 0, 0.25); |
61 | 75 | }
|
62 | 76 |
|
63 | 77 | input[type="submit"] {
|
64 |
| - padding: 10px 15px; |
65 |
| - background-color: #007BFF; |
| 78 | + padding: 12px 20px; |
| 79 | + background: linear-gradient(135deg, #ff9800, #e65100); |
66 | 80 | color: #fff;
|
67 | 81 | border: none;
|
68 | 82 | border-radius: 4px;
|
69 | 83 | cursor: pointer;
|
70 |
| - transition: background-color 0.3s ease, transform 0.3s ease; |
| 84 | + transition: background 0.3s ease, transform 0.3s ease, box-shP0+r\P0+r\P0+r\P0+r\P0+r\adow 0.3s ease; |
| 85 | + font-size: 16px; |
71 | 86 | }
|
72 | 87 |
|
73 | 88 | input[type="submit"]:hover {
|
74 |
| - background-color: #0056b3; |
| 89 | + background: linear-gradient(135deg, #e65100, #ff9800); |
| 90 | + box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1); |
75 | 91 | transform: translateY(-2px);
|
76 | 92 | }
|
77 | 93 |
|
78 | 94 | input[type="submit"]:active {
|
79 | 95 | transform: translateY(0);
|
| 96 | + box-shadow: none; |
80 | 97 | }
|
81 | 98 |
|
82 | 99 | @media (max-width: 600px) {
|
83 | 100 | .container {
|
84 |
| - margin: 20px 10px; |
| 101 | + padding: 20px; |
| 102 | + margin: 10px; |
| 103 | + } |
| 104 | + |
| 105 | + h1 { |
| 106 | + font-size: 1.5rem; |
85 | 107 | }
|
86 | 108 |
|
87 |
| - input[type="text"] { |
| 109 | + p { |
| 110 | + font-size: 0.9rem; |
| 111 | + } |
| 112 | + |
| 113 | + input[type="text"], input[type="submit"] { |
88 | 114 | font-size: 14px;
|
89 | 115 | }
|
90 | 116 | }
|
|
93 | 119 |
|
94 | 120 | <body>
|
95 | 121 | <div class="container">
|
96 |
| - <h1>Hello Dosto, |
97 |
| - Let's make a 2 Tier Application with Flask and MYSQL!</h1> |
98 |
| - {% for message in messages %} |
99 |
| - <p>{{ message[0] }}</p> |
100 |
| - {% endfor %} |
101 |
| - |
102 |
| - <form action="/submit" method="post"> |
| 122 | + <h1>Hello Dosto,<br>Let's make a 2 Tier Application with Flask and MYSQL!</h1> |
| 123 | + <div class="messages"> |
| 124 | + {% for message in messages %} |
| 125 | + <p>{{ message[0] }}</p> |
| 126 | + {% endfor %} |
| 127 | + </div> |
| 128 | + |
| 129 | + <form id="messageForm"> |
103 | 130 | <input type="text" name="new_message" placeholder="Enter a new message">
|
104 | 131 | <input type="submit" value="Submit">
|
105 | 132 | </form>
|
106 | 133 | </div>
|
| 134 | + |
| 135 | + <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script> |
| 136 | + <script> |
| 137 | + $(document).ready(function() { |
| 138 | + $("#messageForm").on("submit", function(event) { |
| 139 | + event.preventDefault(); // Prevent the form from submitting the traditional way |
| 140 | + |
| 141 | + $.ajax({ |
| 142 | + url: "/submit", |
| 143 | + type: "POST", |
| 144 | + data: { |
| 145 | + new_message: $("input[name='new_message']").val() |
| 146 | + }, |
| 147 | + success: function(response) { |
| 148 | + if (response && response.message) { |
| 149 | + // Append the new message to the list of messages |
| 150 | + $(".messages").append("<p>" + response.message + "</p>"); |
| 151 | + // Clear the input field |
| 152 | + $("input[name='new_message']").val(""); |
| 153 | + } else { |
| 154 | + console.error("Unexpected response format:", response); |
| 155 | + } |
| 156 | + }, |
| 157 | + error: function(xhr, status, error) { |
| 158 | + console.error("AJAX Error:", status, error); |
| 159 | + } |
| 160 | + }); |
| 161 | + }); |
| 162 | + }); |
| 163 | + </script> |
107 | 164 | </body>
|
108 | 165 |
|
109 | 166 | </html>
|
| 167 | + |
0 commit comments