my-cloud-devops-consulting 5.5.9__py3-none-any.whl → 5.7.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 +65 -13
- {my_cloud_devops_consulting-5.5.9.dist-info → my_cloud_devops_consulting-5.7.9.dist-info}/METADATA +1 -1
- my_cloud_devops_consulting-5.7.9.dist-info/RECORD +5 -0
- my_cloud_devops_consulting-5.5.9.dist-info/RECORD +0 -5
- {my_cloud_devops_consulting-5.5.9.dist-info → my_cloud_devops_consulting-5.7.9.dist-info}/WHEEL +0 -0
- {my_cloud_devops_consulting-5.5.9.dist-info → my_cloud_devops_consulting-5.7.9.dist-info}/top_level.txt +0 -0
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
|
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 =
|
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
|
-
|
11
|
-
|
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
|
-
|
32
|
-
|
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
|
-
|
36
|
-
return
|
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('
|
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
141
|
app.run(debug=True, host='0.0.0.0', port=50)
|
142
|
+
|
143
|
+
|
144
|
+
|
@@ -0,0 +1,5 @@
|
|
1
|
+
app.py,sha256=U5YTqEzR0vL3RBybNGr2W0MUxqKL8nca6NGHTVb_GBM,5068
|
2
|
+
my_cloud_devops_consulting-5.7.9.dist-info/METADATA,sha256=IA625bc5HeyGMMvbVZ-y57_tWb-grod4Ey3k1UWthvI,1134
|
3
|
+
my_cloud_devops_consulting-5.7.9.dist-info/WHEEL,sha256=1tXe9gY0PYatrMPMDd6jXqjfpz_B-Wqm32CPfRC58XU,91
|
4
|
+
my_cloud_devops_consulting-5.7.9.dist-info/top_level.txt,sha256=io9g7LCbfmTG1SFKgEOGXmCFB9uMP2H5lerm0HiHWQE,4
|
5
|
+
my_cloud_devops_consulting-5.7.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,,
|
{my_cloud_devops_consulting-5.5.9.dist-info → my_cloud_devops_consulting-5.7.9.dist-info}/WHEEL
RENAMED
File without changes
|
File without changes
|