Permalink
Show file tree
Hide file tree
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
6 changed files
with
205 additions
and
0 deletions.
There are no files selected for viewing
33
main.py
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
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() |
18
make_db.py
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
from flask import Flask | ||
from flask import render_template | ||
import sqlite3 | ||
|
||
con = sqlite3.connect('events.db') | ||
|
||
con.execute('CREATE TABLE events(id INT unsigned, name VARCHAR(255), date TEXT, time TEXT, image TEXT, description TEXT)') | ||
|
||
con.close() | ||
con = sqlite3.connect('events.db') | ||
|
||
con.execute('INSERT INTO events(id, name, date, time, image, description) VALUES (1, "Rog and Anne", "2022-06-05", "12:00", "event-images/RA.jpg", "Wedding of Rog and Anne, Harston Church, Harston"),(2, "Sue and Keiko", "2022-08-01", "14:00", "event-images/SK.jpg", "Wedding of Sue and Keiko, Cambridge Registry Office, Cambridge");') | ||
|
||
con.commit() | ||
con.close() | ||
|
||
|
||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,124 @@ | ||
body { | ||
font-family: Arial; | ||
color: #211a1a; | ||
font-size: 0.9em; | ||
} | ||
|
||
#shopping-cart { | ||
margin: 40px; | ||
} | ||
|
||
#event-grid { | ||
margin: 40px; | ||
} | ||
|
||
#shopping-cart table { | ||
width: 100%; | ||
background-color: #F0F0F0; | ||
} | ||
|
||
#shopping-cart table td { | ||
background-color: #FFFFFF; | ||
} | ||
|
||
.txt-heading { | ||
color: #211a1a; | ||
border-bottom: 1px solid #E0E0E0; | ||
overflow: auto; | ||
} | ||
|
||
#btnEmpty { | ||
background-color: #ffffff; | ||
border: #d00000 1px solid; | ||
padding: 5px 10px; | ||
color: #d00000; | ||
float: right; | ||
text-decoration: none; | ||
border-radius: 3px; | ||
margin: 10px 0px; | ||
} | ||
|
||
.btnAddAction { | ||
padding: 5px 10px; | ||
margin-left: 5px; | ||
background-color: #efefef; | ||
border: #E0E0E0 1px solid; | ||
color: #211a1a; | ||
float: right; | ||
text-decoration: none; | ||
border-radius: 3px; | ||
cursor: pointer; | ||
} | ||
|
||
#event-grid .txt-heading { | ||
margin-bottom: 18px; | ||
} | ||
|
||
.event-item { | ||
float: left; | ||
background: #ffffff; | ||
margin: 30px 30px 0px 0px; | ||
border: #E0E0E0 1px solid; | ||
} | ||
|
||
.event-image { | ||
height: 155px; | ||
width: 250px; | ||
background-color: #FFF; | ||
} | ||
|
||
.clear-float { | ||
clear: both; | ||
} | ||
|
||
.demo-input-box { | ||
border-radius: 2px; | ||
border: #CCC 1px solid; | ||
padding: 2px 1px; | ||
} | ||
|
||
.tbl-cart { | ||
font-size: 0.9em; | ||
} | ||
|
||
.tbl-cart th { | ||
font-weight: normal; | ||
} | ||
|
||
.event-title { | ||
margin-bottom: 20px; | ||
} | ||
|
||
.product-price { | ||
float:left; | ||
} | ||
|
||
.cart-action { | ||
float: right; | ||
} | ||
|
||
.product-quantity { | ||
padding: 5px 10px; | ||
border-radius: 3px; | ||
border: #E0E0E0 1px solid; | ||
} | ||
|
||
.product-tile-footer { | ||
padding: 15px 15px 0px 15px; | ||
overflow: auto; | ||
} | ||
|
||
.cart-item-image { | ||
width: 30px; | ||
height: 30px; | ||
border-radius: 50%; | ||
border: #E0E0E0 1px solid; | ||
padding: 5px; | ||
vertical-align: middle; | ||
margin-right: 15px; | ||
} | ||
.no-records { | ||
text-align: center; | ||
clear: both; | ||
margin: 38px 0px; | ||
} |
BIN
+12.4 KB
static/images/event-images/RA.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN
+10.2 KB
static/images/event-images/SK.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>Giftlist</title> | ||
<link href="{{ url_for('static', filename='css/style.css') }}" rel="stylesheet" type="text/css" /> | ||
</head> | ||
<body> | ||
<div id="event-grid"> | ||
<div class="txt-heading">Events</div> | ||
|
||
{% for event in events %} | ||
|
||
|
||
<div class="event-item"> | ||
<form method="post" action="/add"> | ||
<div class="event-image"><img src="/static/images/{{ event[4] }}"></div> | ||
<div class="product-tile-footer"> | ||
<div class="event-title">{{ event[1] }}</div> | ||
<div class="event-date">{{ event[2] }}</div> | ||
<div class="event-time">{{ event[3] }}</div> | ||
<div class="event-description">{{ event[5] }}</div> | ||
</div> | ||
</form> | ||
</div> | ||
|
||
{% endfor %} | ||
|
||
</div> | ||
</body> | ||
</html> |