-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
141 lines (104 loc) · 3.44 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
import os
import requests # use 'pip install requests' if not included
from flask import (
Flask,
flash,
make_response,
redirect,
render_template,
request,
url_for,
)
from route.routes1 import server_bp
# from markupsafe import Markup # Import Markup from markupsafe
app = Flask(__name__)
app.register_blueprint(server_bp)
app.secret_key = os.getenv('FLASH_KEY') # Needed for flashing messages
RECAPTCHA_SECRET_KEY = os.getenv('RECAPTCHA_SECRET_KEY')
# Homepage
@app.route("/home")
def home():
return render_template("home.html")
@app.route("/home2")
def home2():
return render_template("home2.html")
@app.route("/about")
def about():
return render_template("about.html")
@app.route("/privacy")
def privacy():
return render_template("privacy.html")
@app.route("/contact")
def contact():
return render_template("contact.html")
@app.route("/faq")
def faq():
return render_template("faq.html")
@app.route("/test")
def test():
return render_template("test.html")
@app.route("/test2")
def test2():
return render_template("test2.html")
@app.route("/entry")
def entry():
return render_template("entry.html")
@app.route("/checkout")
def checkout():
return render_template("checkout.html")
@app.route("/profile")
def profile():
return render_template("profile.html")
@app.route('/submit_form', methods=['POST'])
def submit_form():
app.logger.info("Form Submission started")
flash('Testing', 'danger')
name = request.form.get('name')
email = request.form.get('email')
message = request.form.get('message')
recaptcha_response = request.form.get('g-recaptcha-response')
print("Form received by ", name, " with email ", email, " and message ",
message)
if not recaptcha_response:
flash('Please complete the reCAPTCHA', 'danger')
print('Incomplete reCAPTCHA; Form Submission Failed!')
return redirect(url_for('contact'))
verification_url = 'https://www.google.com/recaptcha/api/siteverify'
payload = {'secret': RECAPTCHA_SECRET_KEY, 'response': recaptcha_response}
response = requests.post(verification_url, data=payload)
result = response.json()
if not result.get('success'):
flash('reCAPTCHA verification failed', 'danger')
print('reCAPTCHA Verification failed; Form Submission Failed!')
return redirect(url_for('contact'))
# Process form data (e.g., save to database, send email, etc.)
flash('Form submitted successfully', 'success')
app.logger.info(
"Form submitted by {name} with email {email} and message {message}")
print("Form submitted by ", name, " with email ", email, " and message ",
message)
return redirect(url_for('contact'))
# print(name)
@app.route("/search")
def search():
return render_template("search.html")
@app.route("/addProperty")
def addProperty():
return render_template("property.html")
@app.route("/myhouses")
def myhouses():
return render_template("myhouses.html")
@app.route("/housemodal")
def housemodal():
return render_template("housemodal.html")
# @app.route("/new_cookie")
# def new_cookie():
# response=make_response("HelloWorld!")
# response.set_cookie("myCookie","myValue")
# return response
# @app.route("/show_cookie")
# def show_cookie():
# cookie_value=request.cookies.get('mycookie')
# return cookie_value
if __name__ == '__main__':
app.run(host='0.0.0.0', port=5000)