Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
JH-Giftlist/main.py
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
33 lines (28 sloc)
770 Bytes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from flask import Flask | |
import sqlite3 | |
from flask import flash, session, render_template, request, redirect, url_for | |
from werkzeug.security import generate_password_hash, check_password_hash | |
app = Flask(__name__) | |
app.secret_key = "secret key" | |
@app.route('/') | |
def events(): | |
try: | |
con = sqlite3.connect('events.db') | |
cur = con.cursor(); | |
cur.execute("SELECT * FROM events") | |
rows = cur.fetchall() | |
return render_template('events.html', events=rows) | |
except Exception as e: | |
print(e) | |
finally: | |
cur.close() | |
con.close() | |
@app.route('/empty') | |
def empty_cart(): | |
try: | |
session.clear() | |
return redirect(url_for('.events')) | |
except Exception as e: | |
print(e) | |
if __name__ == "__main__": | |
app.run() |