Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ISSUE #12 feat: add Fan Poll Auth checking and temporary login.html page #28

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
23 changes: 22 additions & 1 deletion app.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,36 @@
from flask import render_template
from flask import redirect
from flask import url_for
from flask import request
from populate import populate
import config
import functools

app = config.app

with app.app_context():
populate(config)

# storing the user details in session after Authentication.
session = {}

# decorator to redirect the use to login.html page
def login_required(func):
@functools.wraps(func)
def secure_function(*args, **kwargs):
if "username" not in session:
return redirect(url_for("login", next=request.url))
return func(*args, **kwargs)
return secure_function

@app.route('/')
def index():
return render_template('index.html')

@app.route('/login')
def login():
return render_template('login.html')

@app.route('/standings')
def standings():
return render_template('standings.html')
Expand All @@ -21,8 +41,9 @@ def fixtures():
return render_template('fixtures.html', fixtures=fixtures)

@app.route('/Fan_Poll')
@login_required
def Fan_Poll():
return render_template('Fan_Poll.html')
return render_template('Fan_Poll.html', username=session["username"])

if __name__ == "__main__":
app.run(debug=True)
Expand Down
Binary file modified instance/database.db
Binary file not shown.
10 changes: 10 additions & 0 deletions templates/login.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{% extends "base.html" %}

{% block head %}
<meta charset="UTF-8">
<title>ICC WorldCup'23</title>
<link rel="stylesheet" href="{{url_for('static', filename='css/style.css')}}">
{% endblock %}
{% block body %}
LOGIN PAGE
{% endblock %}