Skip to content

Commit 44006e4

Browse files
committed
Changes Layouting
1 parent c4e745e commit 44006e4

18 files changed

+45
-48
lines changed

app.py

+45-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,46 @@
1-
from app import app
1+
from . import app
2+
from flask import Flask, render_template
3+
import requests as req
4+
from models.product import Product
5+
6+
app = Flask(__name__)
7+
8+
@app.route('/')
9+
def index():
10+
return render_template("index.html")
11+
12+
@app.route('/about')
13+
def kategori():
14+
return render_template("about.html")
15+
16+
@app.route('/product')
17+
def produk():
18+
products=[]
19+
r=req.get('https://fakestoreapi.com/products')
20+
for product in r.json():
21+
products.append(
22+
Product(
23+
id=product['id'],
24+
title=product['title'],
25+
price=product['price'],
26+
description=product['description'],
27+
category=product['category'],
28+
image=product['image']
29+
)
30+
)
31+
return render_template("product.html", products=products)
32+
33+
@app.route('/contact')
34+
def contact():
35+
return render_template("contact.html")
36+
37+
@app.route('/product/<int:product_id>', methods=['GET'])
38+
def get_product(product_id):
39+
40+
r=req.get(f'https://fakestoreapi.com/products/{product_id}')
41+
product=r.json()
42+
return render_template('detail_produk.html',product=product)
43+
44+
if __name__ == '__main__':
45+
app.run(debug=True)
246

3-
if __name__=="__main__":
4-
app.run(debug=True)

app/__init__.py

-5
This file was deleted.
-254 Bytes
Binary file not shown.
-2.07 KB
Binary file not shown.
-643 Bytes
Binary file not shown.

app/routes.py

-40
This file was deleted.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)