Skip to content

Commit 0b7d615

Browse files
committed
sql merge
1 parent cbd94f3 commit 0b7d615

21 files changed

+385
-234
lines changed

__pycache__/data.cpython-311.pyc

-1.42 KB
Binary file not shown.

app.py

Lines changed: 14 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,19 @@
1-
from flask import Flask, render_template
2-
import data
1+
from flask import Flask
2+
from routes.index_routes import index_blueprint
3+
from routes.browse_routes import browse_blueprint
4+
from routes.error_routes import error_blueprint
5+
from routes.login_routes import login_blueprint
6+
from routes.profile_routes import profile_blueprint
7+
import data, menuData
38

49
app = Flask(__name__)
510

6-
@app.route('/')
7-
def index():
8-
beginner = data.beginner
9-
lecturesData = data.lecturesData
10-
return render_template('index.html', beginner=beginner, lecturesData=lecturesData)
11-
12-
@app.route('/browse')
13-
def browse():
14-
beginner = data.beginner
15-
advanced = data.advanced
16-
return render_template('browse.html', beginner=beginner, advanced=advanced)
17-
18-
@app.route('/myCourses')
19-
def myCourses():
20-
# pass course details here
21-
return render_template('details.html')
22-
23-
@app.route('/details')
24-
def details():
25-
course = data.course
26-
lecturesData = data.lecturesData
27-
beginner = data.beginner
28-
advanced = data.advanced
29-
return render_template('details.html', course=course, lecturesData=lecturesData, beginner=beginner)
30-
31-
@app.route('/profile')
32-
def profile():
33-
return render_template('profile.html')
34-
35-
@app.route('/login')
36-
def login():
37-
return render_template('login.html')
38-
39-
@app.errorhandler(404)
40-
def page_not_found(e):
41-
return render_template('components/error.html'), 404
11+
# Register the Blueprints from separate files
12+
app.register_blueprint(index_blueprint)
13+
app.register_blueprint(browse_blueprint)
14+
app.register_blueprint(error_blueprint)
15+
app.register_blueprint(login_blueprint)
16+
app.register_blueprint(profile_blueprint)
4217

4318
if __name__ == '__main__':
44-
app.run()
19+
app.run()

data.py

Lines changed: 55 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -1,64 +1,4 @@
1-
beginner = [
2-
{
3-
'courseName': 'HTML',
4-
'price': 'Free',
5-
'rating': '4.8',
6-
'link': '#',
7-
'imageName': 'popular-02.jpg'
8-
},
9-
{
10-
'courseName': 'CSS',
11-
'price': 'Free',
12-
'rating': '5.0',
13-
'link': '#',
14-
'imageName': 'popular-01.jpg'
15-
},
16-
{
17-
'courseName': 'JavaScript',
18-
'price': '$4.99',
19-
'rating': '4.8',
20-
'link': '#',
21-
'imageName': 'popular-04.jpg'
22-
},
23-
{
24-
'courseName': 'AWS Basics',
25-
'price': 'Free',
26-
'rating': '5.0',
27-
'link': '#',
28-
'imageName': 'popular-03.jpg'
29-
}
30-
]
31-
32-
advanced = [
33-
{
34-
'courseName': 'Django',
35-
'price': 'Free',
36-
'rating': '4.8',
37-
'link': '#',
38-
'imageName': 'popular-01.jpg'
39-
},
40-
{
41-
'courseName': 'Numpy',
42-
'price': '$4.99',
43-
'rating': '5.0',
44-
'link': '#',
45-
'imageName': 'popular-02.jpg'
46-
},
47-
{
48-
'courseName': 'ML & AI',
49-
'price': '$4.99',
50-
'rating': '5.0',
51-
'link': 'url_for("ML")',
52-
'imageName': 'popular-03.jpg'
53-
},
54-
{
55-
'courseName': 'C#',
56-
'price': '$4.99',
57-
'rating': '5.0',
58-
'link': '#',
59-
'imageName': 'popular-04.jpg'
60-
}
61-
]
1+
#imageName varible only gets used for menu.html macro on search results
622

633
lecturesData = [
644
{
@@ -84,21 +24,71 @@
8424
}
8525
]
8626

87-
course = {
27+
reactjs = {
28+
'courseName': 'ReactJS',#used on search results
8829
'name': 'ReactJS',
89-
'logo' : 'react',
30+
'logo' : 'react-original',
9031
'difficulty': 'Intermediate',
9132
'duration': '1 week',
9233
'rating': '5.0',
9334
'price': 'Free',
35+
'imageName': 'popular-02.jpg',
9436
'description': 'ReactJS is a powerful, efficient and user-friendly JavaScript library for building interactive interfaces.'
9537
}
9638
ML = {
39+
'courseName': 'ML+AI',#used on search results
9740
'name': 'Machine Learning',
98-
'logo': 'python',
99-
'diffculty' : 'Advanced',
41+
'logo': 'python-plain',
42+
'difficulty' : 'Advance',
10043
'duration': '3 week',
10144
'rating': '4.9',
10245
'price': '$25',
46+
'imageName': 'popular-02.jpg',
10347
'description': 'Training computers to learn from data, improving performance without explicit instructions.'
10448
}
49+
JavaScript = {
50+
'courseName': 'JavaScript',#used on search results
51+
'name': 'JavaScript Fundamentals',
52+
'logo': 'javascript-plain',
53+
'difficulty': 'Beginner',
54+
'duration': '4 weeks',
55+
'rating': '4.7',
56+
'price': '$20',
57+
'imageName': 'popular-02.jpg',
58+
'description': 'Learn the basics of JavaScript programming for front-end and back-end development.'
59+
}
60+
61+
Java = {
62+
'courseName': 'Java',#used on search results
63+
'name': 'Java Programming',
64+
'logo': 'java-plain',
65+
'difficulty': 'Intermediate',
66+
'duration': '5 weeks',
67+
'rating': '4.8',
68+
'price': '$30',
69+
'imageName': 'popular-02.jpg',
70+
'description': 'Get started with Java and object-oriented programming for building robust applications.'
71+
}
72+
73+
CSharp = {
74+
'courseName': 'C#',#used on search results
75+
'name': 'C# Essentials',
76+
'logo': 'csharp-plain',
77+
'difficulty': 'Beginner',
78+
'duration': '2 weeks',
79+
'rating': '4.5',
80+
'price': '$15',
81+
'imageName': 'popular-02.jpg',
82+
'description': 'Introduction to C# programming language and its applications in various domains.'
83+
}
84+
Django = {
85+
'courseName': 'Django',#used on search results
86+
'name': 'Django Framework',
87+
'logo': 'django-plain',
88+
'difficulty': 'Intermediate',
89+
'duration': '3 weeks',
90+
'rating': '4.6',
91+
'price': '$25',
92+
'imageName': 'popular-02.jpg',
93+
'description': 'Learn the basics of Django framework for building robust web applications.'
94+
}

menuData.py

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
2+
beginner = [
3+
{
4+
'courseName': 'HTML',
5+
'price': 'Free',
6+
'rating': '4.8',
7+
'imageName': 'popular-02.jpg'
8+
},
9+
{
10+
'courseName': 'Java',
11+
'price': 'Free',
12+
'rating': '5.0',
13+
'imageName': 'popular-01.jpg'
14+
},
15+
{
16+
'courseName': 'JavaScript',
17+
'price': '$4.99',
18+
'rating': '4.8',
19+
'imageName': 'popular-04.jpg'
20+
},
21+
{
22+
'courseName': 'ReactJS',
23+
'price': 'Free',
24+
'rating': '5.0',
25+
'imageName': 'popular-03.jpg'
26+
}
27+
]
28+
29+
30+
advanced = [
31+
{
32+
'courseName': 'Django',
33+
'price': 'Free',
34+
'rating': '4.8',
35+
'imageName': 'popular-01.jpg'
36+
},
37+
{
38+
'courseName': 'Numpy',
39+
'price': '$4.99',
40+
'rating': '5.0',
41+
'imageName': 'popular-02.jpg'
42+
},
43+
{
44+
'courseName': 'ML+AI',
45+
'price': '$4.99',
46+
'rating': '5.0',
47+
'imageName': 'popular-03.jpg'
48+
},
49+
{
50+
'courseName': 'C#',
51+
'price': '$4.99',
52+
'rating': '5.0',
53+
'imageName': 'popular-04.jpg'
54+
}
55+
]

routes/browse_routes.py

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
from flask import Blueprint, render_template, redirect, url_for, request
2+
import data, menuData
3+
4+
browse_blueprint = Blueprint('browse', __name__)
5+
6+
# Map the course_name parameter to the corresponding course data using a dictionary
7+
course_mapping = {
8+
'Java': data.Java,
9+
'C#': data.CSharp,
10+
'ReactJS': data.reactjs,
11+
'ML+AI': data.ML,
12+
'JavaScript': data.JavaScript,
13+
'Django': data.Django
14+
# Add more courses here as needed
15+
}
16+
17+
@browse_blueprint.route('/browse/<course_name>', endpoint='browse_details')
18+
def details(course_name):
19+
20+
# Check if the given course_name exists in the mapping, if not, return an error or redirect
21+
if course_name not in course_mapping:
22+
return render_template('components/error.html')
23+
24+
# Get the corresponding course data from the course_mapping
25+
course = course_mapping[course_name]
26+
lecturesData = data.lecturesData
27+
beginner = menuData.beginner
28+
return render_template('details.html', course=course, lecturesData=lecturesData, beginner=beginner)
29+
30+
@browse_blueprint.route('/browse', endpoint='browse_home', methods=['GET', 'POST'])
31+
def browse():
32+
beginner = menuData.beginner
33+
advanced = menuData.advanced
34+
35+
# If the form is submitted (POST request), get the search keyword from the form
36+
if request.method == 'POST':
37+
search_keyword = request.form.get('searchKeyword')
38+
# Perform the search based on the search_keyword and filter the courses
39+
filtered_courses = []
40+
for course_name, course_data in course_mapping.items():
41+
if search_keyword.lower() in course_name.lower():
42+
filtered_courses.append(course_data)
43+
return render_template('browse.html', beginner=beginner, advanced=advanced, search_keyword=search_keyword, search_results=filtered_courses)
44+
45+
# If it's a GET request, show the regular browse page without search results
46+
return render_template('browse.html', beginner=beginner, advanced=advanced)

routes/error_routes.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
from flask import Blueprint, render_template
2+
3+
error_blueprint = Blueprint('error', __name__)
4+
5+
@error_blueprint.errorhandler(404)
6+
def page_not_found(e):
7+
return render_template('components/error.html'), 404

routes/index_routes.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
from flask import Blueprint, render_template
2+
import menuData,data
3+
4+
index_blueprint = Blueprint('index', __name__)
5+
6+
@index_blueprint.route('/',endpoint='index')
7+
def index():
8+
beginner = menuData.beginner
9+
lecturesData = data.lecturesData
10+
return render_template('index.html', beginner=beginner, lecturesData=lecturesData)

routes/login_routes.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
from flask import Blueprint, render_template
2+
3+
login_blueprint = Blueprint('login', __name__)
4+
5+
@login_blueprint.route('/login')
6+
def login():
7+
return render_template('login.html')

routes/profile_routes.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
from flask import Blueprint, render_template
2+
3+
profile_blueprint = Blueprint('profile', __name__)
4+
5+
@profile_blueprint.route('/profile')
6+
def profile():
7+
return render_template('profile.html')

static/assets/css/templatemo-cyborg-gaming.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ body {
168168

169169
body .page-content {
170170
margin-top: 110px;
171-
background-color: #010b13;
171+
background-color: #01111d;
172172
padding: 60px;
173173
border-radius: 23px;
174174
}

0 commit comments

Comments
 (0)