-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
65 lines (49 loc) · 1.9 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
# Modules & Classes
from flask import Flask, render_template, request, jsonify
from flask import redirect, url_for
from api_main import APIhandler
# variable for module's name
app = Flask(__name__)
# Username & Password set for login page
valid_username = "admin"
valid_password = "1qaz2wsx"
# Standardize credentials for login page
credentials = valid_username.lower(), valid_password
#login page
@app.route("/")
def login_page():
return render_template("login.html")
#username & password performs the cross-checks
@app.route("/login", methods=["POST"])
def login():
entered_username = request.form.get("username")
entered_password = request.form.get("password")
entered_credentials = entered_username.lower(), entered_password
if entered_credentials == credentials:
return redirect(url_for("home"))
else:
return redirect(url_for("login_page", error=1))
#Redirects to /home if the credentials are correct.
#Homepage, which I added 3 Hyperlinks. geocoding, forecast weather, credits
@app.route("/home")
def home():
return render_template("homepage.html")
#Geocoding App Page, which basically for users to fill up the inputs.
@app.route("/geocoding-app")
def geocoding_app():
return render_template("geocoding.html")
#The output of the API Package Data's will be in this.
@app.route("/process-geocoding", methods=["POST"])
def process_geocoding():
location = request.form.get("location")
count = request.form.get("count")
api_handler = APIhandler(location, count)
response = api_handler.Geocoding_data()
return jsonify(response)
#Credits
@app.route("/credits")
def credits():
return "Credits truly goes to GA Instructor for the guidance & support: Deeban, Yi Han, Zahid"
#implements the code even while the script is running behind the scene.
if __name__ == "__main__":
app.run(debug=True)