Skip to content
This repository was archived by the owner on Jan 2, 2026. It is now read-only.

Commit 7bb1281

Browse files
committed
Small changes to the examples
1 parent f288815 commit 7bb1281

File tree

4 files changed

+97
-11
lines changed

4 files changed

+97
-11
lines changed
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@
88

99
@app.route('/')
1010
def index():
11-
items = db.get_all()
11+
items = db.get_database("my_database").get_collection("items").find().to_list()
1212
return render_template('index.html', items=items)
1313

1414
@app.route('/add', methods=['POST'])
1515
def add_item():
16-
key = request.form['key']
17-
value = request.form['value']
18-
db.set(key, value)
16+
item_name = request.form.get('item_name')
17+
if item_name:
18+
db.get_database("my_database").get_collection("items").insert_one({'name': item_name})
1919
return redirect(url_for('index'))
2020

2121
if __name__ == '__main__':
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
body {
2+
font-family: 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
3+
background-color: #f8f9fa; /* Light gray background */
4+
color: #343a40; /* Dark gray text */
5+
}
6+
7+
.container {
8+
max-width: 960px; /* Limit container width for better readability */
9+
}
10+
11+
h1, h2 {
12+
color: #0056b3; /* A shade of blue for headings */
13+
font-weight: 600;
14+
}
15+
16+
.card {
17+
border: none;
18+
border-radius: 0.75rem; /* More rounded corners */
19+
box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.08); /* Softer shadow */
20+
overflow: hidden; /* Ensures content respects border-radius */
21+
}
22+
23+
.card-header {
24+
background-color: #e9ecef; /* Light gray header */
25+
border-bottom: 1px solid rgba(0, 0, 0, 0.08);
26+
padding: 1.25rem 1.5rem;
27+
}
28+
29+
.form-control {
30+
border-radius: 0.5rem; /* Rounded input fields */
31+
border: 1px solid #ced4da;
32+
padding: 0.75rem 1rem;
33+
}
34+
35+
.form-control:focus {
36+
border-color: #80bdff;
37+
box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
38+
}
39+
40+
.btn-primary {
41+
background-color: #007bff;
42+
border-color: #007bff;
43+
border-radius: 0.5rem;
44+
padding: 0.75rem 1.5rem;
45+
font-weight: 500;
46+
transition: all 0.2s ease-in-out;
47+
}
48+
49+
.btn-primary:hover {
50+
background-color: #0056b3;
51+
border-color: #0056b3;
52+
transform: translateY(-1px); /* Slight lift effect */
53+
box-shadow: 0 0.25rem 0.5rem rgba(0, 123, 255, 0.2);
54+
}
55+
56+
.list-group-item {
57+
border-color: rgba(0, 0, 0, 0.08);
58+
padding: 1rem 1.5rem;
59+
}
60+
61+
.list-group-item:last-child {
62+
border-bottom-right-radius: 0.75rem;
63+
border-bottom-left-radius: 0.75rem;
64+
}
65+
66+
.list-group-item:first-child {
67+
border-top-right-radius: 0.75rem;
68+
border-top-left-radius: 0.75rem;
69+
}
70+
71+
/* Custom scrollbar for better aesthetics (optional, but modern) */
72+
::-webkit-scrollbar {
73+
width: 8px;
74+
}
75+
76+
::-webkit-scrollbar-track {
77+
background: #f1f1f1;
78+
border-radius: 10px;
79+
}
80+
81+
::-webkit-scrollbar-thumb {
82+
background: #888;
83+
border-radius: 10px;
84+
}
85+
86+
::-webkit-scrollbar-thumb:hover {
87+
background: #555;
88+
}
Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
<meta name="viewport" content="width=device-width, initial-scale=1.0">
66
<title>MainyDB Web App</title>
77
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH" crossorigin="anonymous">
8+
<link rel="stylesheet" href="{{ url_for('static', filename='css/style.css') }}">
89
</head>
910
<body>
1011
<div class="container mt-5">
@@ -16,11 +17,8 @@ <h2>Add New Item</h2>
1617
</div>
1718
<div class="card-body">
1819
<form action="/add" method="post" class="row g-3">
19-
<div class="col-md-5">
20-
<input type="text" name="key" class="form-control" placeholder="Key" required>
21-
</div>
22-
<div class="col-md-5">
23-
<input type="text" name="value" class="form-control" placeholder="Value" required>
20+
<div class="col-md-10">
21+
<input type="text" name="item_name" class="form-control" placeholder="Item Name" required>
2422
</div>
2523
<div class="col-md-2">
2624
<button type="submit" class="btn btn-primary w-100">Add Item</button>
@@ -36,9 +34,9 @@ <h2>Stored Items</h2>
3634
<div class="card-body">
3735
{% if items %}
3836
<ul class="list-group">
39-
{% for key, value in items.items() %}
37+
{% for item in items %}
4038
<li class="list-group-item d-flex justify-content-between align-items-center">
41-
<strong>{{ key }}:</strong> {{ value }}
39+
<strong>Item:</strong> {{ item.name }}
4240
</li>
4341
{% endfor %}
4442
</ul>

0 commit comments

Comments
 (0)