init small flask ui
parent
938fee1a4e
commit
57233055eb
|
|
@ -0,0 +1,27 @@
|
||||||
|
from flask import Flask, render_template, redirect, url_for
|
||||||
|
|
||||||
|
app = Flask(__name__)
|
||||||
|
|
||||||
|
@app.route('/')
|
||||||
|
def home():
|
||||||
|
return redirect(url_for('products'))
|
||||||
|
|
||||||
|
@app.route('/cart')
|
||||||
|
def cart():
|
||||||
|
cart_items = [
|
||||||
|
{'name': 'Item 1', 'quantity': 2},
|
||||||
|
{'name': 'Item 2', 'quantity': 1}
|
||||||
|
]
|
||||||
|
return render_template('cart.html', cart_items=cart_items)
|
||||||
|
|
||||||
|
@app.route('/products')
|
||||||
|
def products():
|
||||||
|
products = [
|
||||||
|
{'name': 'Product 1', 'price': 2.5},
|
||||||
|
{'name': 'Product 2', 'price': 1.5}
|
||||||
|
]
|
||||||
|
return render_template('product.html', products=products)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
app.run(debug=True, port=5000)
|
||||||
|
|
@ -0,0 +1,18 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>{% block title %}My Shop{% endblock %}</title>
|
||||||
|
<link rel="stylesheet" href="{{ url_for('static', filename='css/style.css') }}">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<header>
|
||||||
|
<h1>My Shop</h1>
|
||||||
|
</header>
|
||||||
|
<main>
|
||||||
|
{% block content %}{% endblock %}
|
||||||
|
</main>
|
||||||
|
<script src="{{ url_for('static', filename='js/script.js') }}"></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
|
@ -0,0 +1,12 @@
|
||||||
|
{% extends "base.html" %}
|
||||||
|
|
||||||
|
{% block title %}Cart{% endblock %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<h2>Cart Items</h2>
|
||||||
|
<ul>
|
||||||
|
{% for item in cart_items %}
|
||||||
|
<li>{{ item.name }} - {{ item.quantity }}</li>
|
||||||
|
{% endfor %}
|
||||||
|
</ul>
|
||||||
|
{% endblock %}
|
||||||
|
|
@ -0,0 +1,14 @@
|
||||||
|
{% extends "base.html" %}
|
||||||
|
|
||||||
|
{% block title %}Products{% endblock %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<h2>Product Items</h2>
|
||||||
|
<ul>
|
||||||
|
{% for product in products %}
|
||||||
|
<li>{{ product.name }} - ${{ product.price }}</li>
|
||||||
|
{% endfor %}
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
<a href="{{ url_for('cart') }}" class="btn btn-primary">Go to Cart</a>
|
||||||
|
{% endblock %}
|
||||||
Loading…
Reference in New Issue