From 57233055eb6edded3e33849e2e4e14bccf0fd488 Mon Sep 17 00:00:00 2001 From: Felix Mucha <3016498@stud.hs-mannheim.de> Date: Sat, 30 Nov 2024 18:37:17 +0100 Subject: [PATCH] init small flask ui --- src/framework_driver/ui/app.py | 27 +++++++++++++++++++ src/framework_driver/ui/static/css/style.css | 0 src/framework_driver/ui/static/js/script.js | 0 src/framework_driver/ui/templates/base.html | 18 +++++++++++++ src/framework_driver/ui/templates/cart.html | 12 +++++++++ .../ui/templates/product.html | 14 ++++++++++ 6 files changed, 71 insertions(+) create mode 100644 src/framework_driver/ui/app.py create mode 100644 src/framework_driver/ui/static/css/style.css create mode 100644 src/framework_driver/ui/static/js/script.js create mode 100644 src/framework_driver/ui/templates/base.html create mode 100644 src/framework_driver/ui/templates/cart.html create mode 100644 src/framework_driver/ui/templates/product.html diff --git a/src/framework_driver/ui/app.py b/src/framework_driver/ui/app.py new file mode 100644 index 0000000..e6e8e7e --- /dev/null +++ b/src/framework_driver/ui/app.py @@ -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) \ No newline at end of file diff --git a/src/framework_driver/ui/static/css/style.css b/src/framework_driver/ui/static/css/style.css new file mode 100644 index 0000000..e69de29 diff --git a/src/framework_driver/ui/static/js/script.js b/src/framework_driver/ui/static/js/script.js new file mode 100644 index 0000000..e69de29 diff --git a/src/framework_driver/ui/templates/base.html b/src/framework_driver/ui/templates/base.html new file mode 100644 index 0000000..84b0250 --- /dev/null +++ b/src/framework_driver/ui/templates/base.html @@ -0,0 +1,18 @@ + + + + + + {% block title %}My Shop{% endblock %} + + + +
+

My Shop

+
+
+ {% block content %}{% endblock %} +
+ + + \ No newline at end of file diff --git a/src/framework_driver/ui/templates/cart.html b/src/framework_driver/ui/templates/cart.html new file mode 100644 index 0000000..af078b7 --- /dev/null +++ b/src/framework_driver/ui/templates/cart.html @@ -0,0 +1,12 @@ +{% extends "base.html" %} + +{% block title %}Cart{% endblock %} + +{% block content %} +

Cart Items

+ +{% endblock %} \ No newline at end of file diff --git a/src/framework_driver/ui/templates/product.html b/src/framework_driver/ui/templates/product.html new file mode 100644 index 0000000..fff92ae --- /dev/null +++ b/src/framework_driver/ui/templates/product.html @@ -0,0 +1,14 @@ +{% extends "base.html" %} + +{% block title %}Products{% endblock %} + +{% block content %} +

Product Items

+ + +Go to Cart +{% endblock %} \ No newline at end of file