my-cloud-devops-consulting 5.5.9__py3-none-any.whl → 5.6.9__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
app.py CHANGED
@@ -1,19 +1,41 @@
1
- from flask import Flask, render_template, request, redirect, url_for, session, flash
1
+ from flask import Flask, render_template, request, redirect, url_for, session, flash,jsonify
2
2
  from pymongo import MongoClient
3
3
  from werkzeug.security import generate_password_hash, check_password_hash
4
4
  from urllib.parse import quote_plus
5
- import os
5
+ from bson.objectid import ObjectId
6
6
 
7
+ import os
8
+ from flask_login import LoginManager,login_user,UserMixin,login_required,logout_user,current_user
9
+ from settings import SECRET_KEY,MONGO_URI, EMAIL_USER
10
+ from utils import send_email, get_videos
7
11
  app = Flask(__name__)
8
- app.secret_key = os.environ.get('SECRET_KEY', 'your_secret_key') # Secure your secret key with an environment variable
12
+ app.secret_key = SECRET_KEY # Secure your secret key with an environment variable
13
+ login_manager = LoginManager()
14
+
15
+ login_manager.init_app(app)
9
16
 
10
- # MongoDB Configuration with properly escaped credentials
11
- username = quote_plus("betrand1999") # add username and pst
12
- password = quote_plus("Cameroon@10K")
13
- client = MongoClient(f"mongodb+srv://{username}:{password}@cluster.7plpy.mongodb.net/my-database?retryWrites=true&w=majority")
17
+
18
+ client = MongoClient(MONGO_URI)
14
19
  db = client['my-database'] # Specify your database as shown in the MongoDB Atlas interface
15
20
  users_collection = db['inventory_collection'] # Collection for storing user data
16
21
 
22
+
23
+
24
+ class User(UserMixin):
25
+ def __init__(self, user_id, username):
26
+ self.id = str(user_id)
27
+ self.username = username
28
+
29
+ @staticmethod
30
+ def get(user_id):
31
+ user = users_collection.find_one({"_id": ObjectId(user_id)})
32
+ if user:
33
+ return User(user["_id"], user["username"])
34
+ return None
35
+ @login_manager.user_loader
36
+ def load_user(user_id):
37
+ return User.get(user_id)
38
+
17
39
  @app.route('/')
18
40
  def home():
19
41
  video_url = None
@@ -23,21 +45,28 @@ def home():
23
45
 
24
46
  @app.route('/login', methods=['GET', 'POST'])
25
47
  def login():
48
+ if current_user.is_authenticated:
49
+ return redirect(url_for('home'))
26
50
  if request.method == 'POST':
27
51
  username = request.form['username']
28
52
  password = request.form['password']
53
+
29
54
  user = users_collection.find_one({'username': username})
55
+ print(user)
30
56
  if user and check_password_hash(user['password'], password):
31
- session['username'] = username
32
- flash('Login successful', 'success')
33
- return redirect(url_for('home'))
57
+ user_obj =User(user["_id"], user["username"])
58
+ login_user(user_obj)
59
+ # return redirect(url_for('home'))
60
+ return jsonify({"message":"Login successful", "status": 200})
34
61
  else:
35
- flash('Invalid username or password', 'error')
36
- return redirect(url_for('login'))
62
+ # return redirect(url_for('login'))
63
+ return jsonify({"message":"Invalid username or password", "status": 400})
37
64
  return render_template('login.html')
38
65
 
39
66
  @app.route('/register', methods=['GET', 'POST'])
40
67
  def register():
68
+ if current_user.is_authenticated:
69
+ return redirect(url_for('home'))
41
70
  if request.method == 'POST':
42
71
  username = request.form['username']
43
72
  password = request.form['password']
@@ -79,14 +108,37 @@ def contact_form():
79
108
  'appointment': appointment,
80
109
  'message': message
81
110
  }
111
+ print("Contact Data: ", contact_data)
82
112
  db.contacts.insert_one(contact_data)
113
+
114
+ send_email('New Contact Form Submission', EMAIL_USER, f'Name: {name}\nEmail: {email}\nPhone: {phone}\nCategory: {category}\nAppointment: {appointment}\nMessage: {message}')
115
+ send_email('Thanks for contacting', email, "We will get back to you soon!")
116
+
117
+
83
118
 
84
119
  # Remove the email or SMS notification logic here
85
120
  # Simply flash a success message
86
121
  flash('Your message has been submitted successfully!', 'success')
87
122
 
88
- return redirect(url_for('home'))
123
+ return redirect(url_for('contact_form'))
89
124
  return render_template('contact-form.html')
90
125
 
126
+
127
+ @app.route('/videos')
128
+ # @login_required
129
+ def private_videos():
130
+ if not current_user.is_authenticated:
131
+ return redirect(url_for('login'))
132
+ videos = get_videos()
133
+ return render_template('private-videos.html', videos=videos)
134
+ @app.route("/logout")
135
+ @login_required
136
+ def logout():
137
+ logout_user()
138
+ flash("Logged out successfully!", "info")
139
+ return redirect(url_for("login"))
91
140
  if __name__ == '__main__':
92
- app.run(debug=True, host='0.0.0.0', port=50)
141
+ app.run(debug=True, host='0.0.0.0', port=80)
142
+
143
+
144
+
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: my-cloud-devops-consulting
3
- Version: 5.5.9
3
+ Version: 5.6.9
4
4
  Summary: This is my consulting website for Cloud & DevOps services.
5
5
  Home-page: https://github.com/Betrand1999/project-root
6
6
  Author: Betrand Mutagha
@@ -0,0 +1,5 @@
1
+ app.py,sha256=tctzrvi-eJD4_NXASVxn5d90nk7LI62mwNh4GCz8V1E,5068
2
+ my_cloud_devops_consulting-5.6.9.dist-info/METADATA,sha256=HrbFnHfSZtmKynkKCiNLaTqQi4ccCIry8J5b47RFv-w,1134
3
+ my_cloud_devops_consulting-5.6.9.dist-info/WHEEL,sha256=1tXe9gY0PYatrMPMDd6jXqjfpz_B-Wqm32CPfRC58XU,91
4
+ my_cloud_devops_consulting-5.6.9.dist-info/top_level.txt,sha256=io9g7LCbfmTG1SFKgEOGXmCFB9uMP2H5lerm0HiHWQE,4
5
+ my_cloud_devops_consulting-5.6.9.dist-info/RECORD,,
@@ -1,5 +0,0 @@
1
- app.py,sha256=RvPlxavixnq9M9Dma8sUlqmwz9YbQDuOR3E0YK-ig4Q,3612
2
- my_cloud_devops_consulting-5.5.9.dist-info/METADATA,sha256=NmVtOfJCvHWK8mmEAM3CRT64q2-IiwTcAi_U7Bp3xbA,1134
3
- my_cloud_devops_consulting-5.5.9.dist-info/WHEEL,sha256=1tXe9gY0PYatrMPMDd6jXqjfpz_B-Wqm32CPfRC58XU,91
4
- my_cloud_devops_consulting-5.5.9.dist-info/top_level.txt,sha256=io9g7LCbfmTG1SFKgEOGXmCFB9uMP2H5lerm0HiHWQE,4
5
- my_cloud_devops_consulting-5.5.9.dist-info/RECORD,,