Spaces:
Runtime error

File size: 2,147 Bytes
cf69cfa
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Stack Simulator</title>
    <!-- Bootstrap CSS -->
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
    <link rel="stylesheet" href="{{ url_for('static', filename='style.css') }}">
</head>
<body class="bg-light">

    <div class="container mt-5">
        <div class="card shadow-sm">
            <div class="card-header bg-primary text-white">
                <h3 class="mb-0">Stack Simulator</h3>
            </div>
            <div class="card-body">

                <!-- Stack Display -->
                <h5 class="mb-3">Current Stack:</h5>
                <ul class="list-group mb-3">
                    {% for item in stack %}
                        <li class="list-group-item">{{ item }}</li>
                    {% else %}
                        <li class="list-group-item text-muted">Stack is empty</li>
                    {% endfor %}
                </ul>

                <!-- Top Element -->
                {% if top %}
                    <div class="alert alert-info">
                        Top element: <strong>{{ top }}</strong>
                    </div>
                {% endif %}

                <!-- Push Form -->
                <form action="/stack/push" method="post" class="d-flex mb-3">
                    <input type="text" name="item" class="form-control me-2" placeholder="Enter item">
                    <button type="submit" class="btn btn-success">Push</button>
                </form>

                <!-- Action Buttons -->
                <div class="d-flex gap-2">
                    <a href="/stack/pop" class="btn btn-danger">Pop</a>
                    <a href="/stack/peek" class="btn btn-warning">Peek</a>
                </div>

                <div class="mt-3">
                    <a href="/" class="btn btn-secondary">Back to Hub</a>
                </div>

            </div>
        </div>
    </div>

    <!-- Bootstrap JS -->
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html>