-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
871c905
commit c47501b
Showing
8 changed files
with
103 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
# db.py | ||
from sqlalchemy import create_engine | ||
from sqlalchemy.orm import sessionmaker | ||
from .models import Base | ||
|
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
from flask import render_template | ||
|
||
def render_error_page(error_code, error_message): | ||
# Render a generic error page | ||
return render_template('error_template.html', error_code=error_code, error_message=error_message), error_code |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
from flask import jsonify, render_template | ||
from src.models.product_model import Product | ||
|
||
def get_product(product_id): | ||
# Fetch product data from the model | ||
product = Product.query.get(product_id) | ||
if product: | ||
return jsonify({"id": product.id, "name": product.name, "price": product.price}), 200 | ||
else: | ||
return jsonify({"error": "Product not found"}), 404 | ||
|
||
def render_product_template(product_id): | ||
# Render a product details page in HTML | ||
product = Product.query.get(product_id) | ||
if product: | ||
return render_template('product_template.html', product=product) | ||
else: | ||
return "Product not found", 404 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
document.addEventListener("DOMContentLoaded", function() { | ||
// Example function to display a welcome message on page load | ||
const userName = document.querySelector("h1"); | ||
if (userName) { | ||
userName.textContent = "Welcome, user!"; // Modify if needed | ||
} | ||
|
||
// Add any other JS functionalities as needed | ||
console.log("App Loaded"); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
body { | ||
font-family: Arial, sans-serif; | ||
margin: 0; | ||
padding: 0; | ||
background-color: #f4f4f4; | ||
} | ||
|
||
header { | ||
background-color: #333; | ||
color: white; | ||
padding: 10px 20px; | ||
text-align: center; | ||
} | ||
|
||
section { | ||
margin: 20px; | ||
padding: 20px; | ||
background-color: white; | ||
border-radius: 8px; | ||
} | ||
|
||
footer { | ||
background-color: #333; | ||
color: white; | ||
text-align: center; | ||
padding: 10px 0; | ||
position: fixed; | ||
width: 100%; | ||
bottom: 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>User Profile</title> | ||
<link rel="stylesheet" href="{{ url_for('static', filename='styles.css') }}"> | ||
</head> | ||
<body> | ||
<header> | ||
<h1>Welcome, {{ user.name }}</h1> | ||
</header> | ||
<section> | ||
<h2>User Information</h2> | ||
<p><strong>ID:</strong> {{ user.id }}</p> | ||
<p><strong>Email:</strong> {{ user.email }}</p> | ||
</section> | ||
<footer> | ||
<p>© 2024 Your Company</p> | ||
</footer> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
from flask import jsonify, render_template | ||
from src.models.user_model import User | ||
|
||
def get_user(user_id): | ||
# Fetch user data from the model | ||
user = User.query.get(user_id) | ||
if user: | ||
return jsonify({"id": user.id, "name": user.name, "email": user.email}), 200 | ||
else: | ||
return jsonify({"error": "User not found"}), 404 | ||
|
||
def render_user_template(user_id): | ||
# Render a user profile page in HTML | ||
user = User.query.get(user_id) | ||
if user: | ||
return render_template('user_template.html', user=user) | ||
else: | ||
return "User not found", 404 |