Compare commits
No commits in common. "a351576000868eab3a9d63737b6bd3f312086438" and "042b25c8e7d01f74c50f9127465f167d44cda646" have entirely different histories.
a351576000
...
042b25c8e7
@ -1,5 +0,0 @@
|
|||||||
Cafe Name,Location,Open,Close,Coffee,Wifi,Power
|
|
||||||
Lighthaus,https://goo.gl/maps/2EvhB4oq4gyUXKXx9,11AM, 3:30PM,☕☕☕☕️,💪💪,🔌🔌🔌
|
|
||||||
Esters,https://goo.gl/maps/13Tjc36HuPWLELaSA,8AM,3PM,☕☕☕☕,💪💪💪,🔌
|
|
||||||
Ginger & White,https://goo.gl/maps/DqMx2g5LiAqv3pJQ9,7:30AM,5:30PM,☕☕☕,✘,🔌
|
|
||||||
Mare Street Market,https://goo.gl/maps/ALR8iBiNN6tVfuAA8,8AM,1PM,☕☕,💪💪💪,🔌🔌🔌
|
|
||||||
|
@ -1,67 +0,0 @@
|
|||||||
from flask import Flask, render_template
|
|
||||||
from flask_bootstrap import Bootstrap5
|
|
||||||
from flask_wtf import FlaskForm
|
|
||||||
from wtforms import StringField, SubmitField
|
|
||||||
from wtforms.validators import DataRequired
|
|
||||||
import csv
|
|
||||||
|
|
||||||
'''
|
|
||||||
Red underlines? Install the required packages first:
|
|
||||||
Open the Terminal in PyCharm (bottom left).
|
|
||||||
|
|
||||||
On Windows type:
|
|
||||||
python -m pip install -r requirements.txt
|
|
||||||
|
|
||||||
On MacOS type:
|
|
||||||
pip3 install -r requirements.txt
|
|
||||||
|
|
||||||
This will install the packages from requirements.txt for this project.
|
|
||||||
'''
|
|
||||||
|
|
||||||
app = Flask(__name__)
|
|
||||||
app.config['SECRET_KEY'] = '8BYkEfBA6O6donzWlSihBXox7C0sKR6b'
|
|
||||||
Bootstrap5(app)
|
|
||||||
|
|
||||||
|
|
||||||
class CafeForm(FlaskForm):
|
|
||||||
cafe = StringField('Cafe name', validators=[DataRequired()])
|
|
||||||
submit = SubmitField('Submit')
|
|
||||||
|
|
||||||
# Exercise:
|
|
||||||
# add: Location URL, open time, closing time, coffee rating, wifi rating, power outlet rating fields
|
|
||||||
# make coffee/wifi/power a select element with choice of 0 to 5.
|
|
||||||
#e.g. You could use emojis ☕️/💪/✘/🔌
|
|
||||||
# make all fields required except submit
|
|
||||||
# use a validator to check that the URL field has a URL entered.
|
|
||||||
# ---------------------------------------------------------------------------
|
|
||||||
|
|
||||||
|
|
||||||
# all Flask routes below
|
|
||||||
@app.route("/")
|
|
||||||
def home():
|
|
||||||
return render_template("index.html")
|
|
||||||
|
|
||||||
|
|
||||||
@app.route('/add')
|
|
||||||
def add_cafe():
|
|
||||||
form = CafeForm()
|
|
||||||
if form.validate_on_submit():
|
|
||||||
print("True")
|
|
||||||
# Exercise:
|
|
||||||
# Make the form write a new row into cafe-data.csv
|
|
||||||
# with if form.validate_on_submit()
|
|
||||||
return render_template('add.html', form=form)
|
|
||||||
|
|
||||||
|
|
||||||
@app.route('/cafes')
|
|
||||||
def cafes():
|
|
||||||
with open('cafe-data.csv', newline='', encoding='utf-8') as csv_file:
|
|
||||||
csv_data = csv.reader(csv_file, delimiter=',')
|
|
||||||
list_of_rows = []
|
|
||||||
for row in csv_data:
|
|
||||||
list_of_rows.append(row)
|
|
||||||
return render_template('cafes.html', cafes=list_of_rows)
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
app.run(debug=True)
|
|
||||||
@ -1,5 +0,0 @@
|
|||||||
Bootstrap_Flask==2.2.0
|
|
||||||
Flask==2.3.2
|
|
||||||
WTForms==3.0.1
|
|
||||||
Flask_WTF==1.2.1
|
|
||||||
Werkzeug==3.0.0
|
|
||||||
@ -1,25 +0,0 @@
|
|||||||
/* This CSS file will need to be added to the styling of
|
|
||||||
your web pages for the styles to be rendered. */
|
|
||||||
|
|
||||||
body {
|
|
||||||
background-color: #333;
|
|
||||||
color: white;
|
|
||||||
}
|
|
||||||
|
|
||||||
a {
|
|
||||||
color: #ffc107;
|
|
||||||
}
|
|
||||||
|
|
||||||
.jumbotron {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
margin: 0;
|
|
||||||
height: 100vh;
|
|
||||||
color: white;
|
|
||||||
background-color: #333;
|
|
||||||
}
|
|
||||||
|
|
||||||
.space-above {
|
|
||||||
margin-top: 20px;
|
|
||||||
padding-top: 20px;
|
|
||||||
}
|
|
||||||
@ -1,20 +0,0 @@
|
|||||||
{% extends 'base.html' %}
|
|
||||||
<!--Don't forget your import here-->
|
|
||||||
{% block title %}Add A New Cafe{% endblock %}
|
|
||||||
|
|
||||||
{% block content %}
|
|
||||||
<div class="container">
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-sm-12 col-md-8">
|
|
||||||
|
|
||||||
<h1>Add a new cafe into the database</h1>
|
|
||||||
|
|
||||||
<!-- This is where your WTForm will go -->
|
|
||||||
|
|
||||||
<p class="space-above"><a href="#">See all cafes</a></p>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{% endblock %}
|
|
||||||
@ -1,21 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html lang="en">
|
|
||||||
<head>
|
|
||||||
<meta charset="UTF-8" />
|
|
||||||
<meta
|
|
||||||
name="viewport"
|
|
||||||
content="width=device-width, initial-scale=1, shrink-to-fit=no"
|
|
||||||
/>
|
|
||||||
|
|
||||||
{% block styles %}
|
|
||||||
<!-- Load Bootstrap-Flask CSS here -->
|
|
||||||
|
|
||||||
<!-- Link to the styles.css here to apply styling to all the child templates.-->
|
|
||||||
|
|
||||||
{% endblock %}
|
|
||||||
<title>{% block title %}{% endblock %}</title>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
{% block content %}{% endblock %}
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@ -1,24 +0,0 @@
|
|||||||
{% extends 'base.html' %}
|
|
||||||
{% block title %}Restaurants{% endblock %}
|
|
||||||
|
|
||||||
{% block content %}
|
|
||||||
|
|
||||||
<div class="container">
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-sm-12">
|
|
||||||
|
|
||||||
<h1>All Cafes</h1>
|
|
||||||
|
|
||||||
<table class="table table-dark table-striped table-hover">
|
|
||||||
<!-- This is where you will write the code to render a Bootstrap
|
|
||||||
Table that contains all the information from the
|
|
||||||
cafe-data.csv file. -->
|
|
||||||
</table>
|
|
||||||
|
|
||||||
<p><a href="#">Return to index page</a></p>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{% endblock %}
|
|
||||||
@ -1,15 +0,0 @@
|
|||||||
{% extends 'base.html' %}
|
|
||||||
{% block title %}Coffee and Wifi{% endblock %}
|
|
||||||
|
|
||||||
{% block content %}
|
|
||||||
<div class="jumbotron text-center">
|
|
||||||
<div class="container">
|
|
||||||
<h1 class="display-4">☕️ Coffee & Wifi 💻</h1>
|
|
||||||
<p class="lead">Want to work in a cafe but need power and wifi?</p>
|
|
||||||
<hr class="my-4">
|
|
||||||
<p>You've found the right place! Checkout my collection of cafes with data on power socket availability, wifi speed and coffee quality.</p>
|
|
||||||
<a class="btn btn-warning btn-lg" href="#" role="button">Show Me!</a>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{% endblock %}
|
|
||||||
@ -7,4 +7,4 @@
|
|||||||
18 June 2025 - Unable to commit due to a lot of tuition home work
|
18 June 2025 - Unable to commit due to a lot of tuition home work
|
||||||
2 September 2025 - Unable to commit due to urgent work
|
2 September 2025 - Unable to commit due to urgent work
|
||||||
5, 6, 7 September - unable to commit due to being on vacation
|
5, 6, 7 September - unable to commit due to being on vacation
|
||||||
8, 9 September - can't commit because I was very sick
|
8 September - can't commit because I was very sick
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user