Skip to content

added a new route #1

New issue

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

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

Already on GitHub? # to your account

Merged
merged 1 commit into from
Jan 8, 2024
Merged
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
118 changes: 86 additions & 32 deletions app.py
Original file line number Diff line number Diff line change
@@ -1,32 +1,86 @@
"""Import Flask from Flask Lib"""
from flask import Flask, render_template

app = Flask(__name__)

# Landing Page
@app.route('/')
def landing_page():
"""Return Landing Page"""
return render_template('index.html')

# Featues Page
@app.route('/features')
def features_page():
"""Return Features Page"""
return render_template('features.html')

# FAQ Page
@app.route('/faq')
def faq_page():
"""Return FAQ Page"""
return render_template('faq.html')

# About Page
@app.route('/about')
def about_page():
"""Return About Page"""
return render_template('about.html')

if __name__ == "__main__":
app.run(debug=False)

# Import necessary libraries
from flask import Flask, render_template, url_for, redirect
from flask_bootstrap import Bootstrap
from models import LoginForm, User, RegisterForm, db, login_man
from flask_sqlalchemy import SQLAlchemy
# from passlib.hash import pbkdf2_sha256
from flask_login import login_required, login_user
#from werkzeug.security import generate_password_hash, check_password_hash

# Run source/venv/bin/activate
app = Flask(__name__)
app.config['SECRET_KEY'] = 'Thisissecret'
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///database.db'
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
app.config['PROPAGATE_EXCEPTIONS'] = True
Bootstrap(app)

db.init_app(app)
login_man.init_app(app)

# ------------------
# Route to home page
@app.route('/')
def home_page():
return render_template('index.html')

# -------------------
# Route for #
@app.route('/#', methods=['GET', 'POST'])
def #():
form = RegisterForm()

if form.validate_on_submit():
# hashed_password = generate_password_hash(form.password.data, method='sha256')
new_user = User(username=form.username.data, password=form.password.data)
db.session.add(new_user)
db.session.commit()
return '<h1>New user has been created!</h1>'
# return '<h1>Welcome ' + form.username.data + '</h1>
return render_template('#.html', form=form)

# -------------------
# Route for FAQ page
@app.route('/faq')
def faq():
return render_template('faq.html')

# ------------------
# Route for Features page
@app.route('/features')
def features():
return render_template('features.html')

# -------------------
# Route for dashboard
@app.route('/dashboard')
@login_required
def dashboard():
return render_template('dashboard.html')

# -------------------
# Route for login
@app.route('/#', methods=['GET', 'POST'])
def login():
form = LoginForm()

if form.validate_on_submit():
user = User.query.filter_by(username=form.username.data).first()
if user:
if user.password == form.password.data:
login_user(user, remember=form.remember_session.data)
return redirect(url_for('dashboard'))
return '<h1>Invalid username or password</h1>'
# return '<h1> Welcome ' + form.username.data + '</h1>'
return render_template('login.html', form=form)


# --------------------
# Route for chatroom
@app.route("/chatroom")
def chatroom():
return render_template("chatroom.html")

# ---------------------------
if __name__ == "__main__":
app.run(debug=True)