Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion python/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
flask
pylint==2.16.1
pylint==2.16.1
gunicorn
12 changes: 12 additions & 0 deletions python/run.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
"""
This module is used to call the flask code.
"""

from src.main import app

# Flask has the built-in Werkzeug server.
# Only run the dev server if this file is executed directly

# host='0.0.0.0' -> Exposes the app to all network interfaces, not just localhost.
# port=8080 -> Binds the app to port 8080.
# debug=True -> Enables debug mode, which provides automatic reload + debugger.
# threaded=True -> Enables multi-threading, so one process can handle multiple requests concurrently

if __name__ == "__main__":
app.debug = True
app.secret_key = "any random string"
Expand Down
5 changes: 5 additions & 0 deletions python/src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@

@app.route("/")
def index():
""" Brief summary of what the function does. """
return render_template("index.html")

@app.route("/login", methods=["GET", "POST"])
def login():
""" Brief summary of what the function does. """
if request.method == "POST":
if valid_login(request.form["t1"], request.form["t2"]):
session["username"] = request.form["t1"]
Expand All @@ -24,13 +26,16 @@ def login():

@app.route("/home")
def home():
""" Brief summary of what the function does. """
return render_template("home.html", user = session["username"])

@app.route("/logout")
def logout():
""" Brief summary of what the function does. """
session.pop("username", None)
return redirect(url_for("login"))

@app.route("/maintenance")
def maintenance():
""" Brief summary of what the function does. """
return "Sorry, we are under maintenance. Try to login with same username and password."
5 changes: 3 additions & 2 deletions python/src/validlogin.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@ def valid_login(username, password):
"""
Checks the validity of the login credentials.

Parameters:
Args:
username (str): The username of the user.
password (str): The password of the user.

Returns:
bool: returns the validity of the login
"""
if((username == password) and username != "" and password != ""):

if (username == password) and username != "" and password != "":
return True
else:
return False