From 1f533832d03528c80a24c641fe15ae01a29358fe Mon Sep 17 00:00:00 2001 From: zevav Date: Tue, 5 Sep 2017 21:35:22 -0400 Subject: [PATCH] flaskify --- 100_blocks.css | 48 ------------------- 100_blocks.html | 17 ------- boards.db | Bin 0 -> 8192 bytes models.py | 18 +++++++ routes.py | 31 ++++++++++++ static/css/100_blocks.css | 49 +++++++++++++++++++ 100_blocks.js => templates/100_blocks.html | 52 ++++++++++++++++++++- 7 files changed, 149 insertions(+), 66 deletions(-) delete mode 100644 100_blocks.css delete mode 100644 100_blocks.html create mode 100644 boards.db create mode 100644 models.py create mode 100644 routes.py create mode 100644 static/css/100_blocks.css rename 100_blocks.js => templates/100_blocks.html (51%) diff --git a/100_blocks.css b/100_blocks.css deleted file mode 100644 index 5842574..0000000 --- a/100_blocks.css +++ /dev/null @@ -1,48 +0,0 @@ -div#gridcontainer -{ - width: 800px; - line-height: 0; - clear: both; -} - -div.griditem, div.palette -{ - display: inline-block; - width: 70px; - height: 70px; - margin-left: 2px; - margin-bottom: 6px; - background: #AAA; - border: 1px solid black; -} - -div.palette { - - border-radius: 50%; - margin-left: 20px; - margin-top: 30px; - border: 2px solid black; - -} - -div#current-palette { - - width: 90px; - height: 90px; - float: right; - margin: 20px 60px 30px; - border: 2px solid black; - -} - -body { - - background: #333; - -} - -#palettes { - -float: left; - -} diff --git a/100_blocks.html b/100_blocks.html deleted file mode 100644 index e09d92b..0000000 --- a/100_blocks.html +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - -
-
-
- - - - - - diff --git a/boards.db b/boards.db new file mode 100644 index 0000000000000000000000000000000000000000..2ba26d6091b9ec91bf0327664f277a9f4a568caa GIT binary patch literal 8192 zcmeI#&r8EF6bJB^G8rq#JUMoIr_q8)>fC*GggLBLV-@Btqg4u5eY$KW+HO-!!F+;?A+St)l%*M3x`e*#)tNn z=)REc2nav`0uX=z1Rwwb2tWV=5P(3F1wM~OyVviFuXbq`%WP4Yb^2D%&P1y)QJjPq zk>dJ{J-3smJc|=GRhr|QgyV-OI$^i7G#|x#$&aC)T!z{Ur1XE)U(G7}sgC{>Z}sdt z)N{U4bN2Gocm4WrzNPNA$^3X51Rwwb2tWV=5P$##AOHafK%kid1JR;sPgW7gp=~31 QX0vM8-MO^cQ?}t?2inm&b^rhX literal 0 HcmV?d00001 diff --git a/models.py b/models.py new file mode 100644 index 0000000..215a893 --- /dev/null +++ b/models.py @@ -0,0 +1,18 @@ +from sqlalchemy import create_engine, Column, String, Integer +from sqlalchemy.orm import sessionmaker +from sqlalchemy.ext.declarative import declarative_base + +Base = declarative_base() + +engine = create_engine('sqlite:///boards.db') +session = sessionmaker(bind=engine)() + + + +class Board(Base): + + __tablename__ = 'boards' + + id = Column(Integer, primary_key=True) + layout = Column(String(100), nullable=False) + name = Column(String(50), nullable=False) diff --git a/routes.py b/routes.py new file mode 100644 index 0000000..d305076 --- /dev/null +++ b/routes.py @@ -0,0 +1,31 @@ +from flask import Flask, render_template, request, jsonify + +app = Flask(__name__) + + +@app.route('/') +def main(): + color_label_dict = {'red':'exercise', + 'blue':'work', + 'yellow':'admin', + 'green':'finance'} + + colors = list(color_label_dict.keys()) + color_num_dict = {'': 0} + color_num_dict = {color: idx + 1 for idx, color in enumerate(colors)} + + return render_template('100_blocks.html', + colors=colors, + color_label_dict=color_label_dict, + color_num_dict=color_num_dict) + + +@app.route('/save/', methods=['POST']) +def save(): + print(vars(request.form)) + return jsonify(vars(request.form)) + + + +if __name__ == '__main__': + app.run(debug=True) diff --git a/static/css/100_blocks.css b/static/css/100_blocks.css new file mode 100644 index 0000000..55119fc --- /dev/null +++ b/static/css/100_blocks.css @@ -0,0 +1,49 @@ +:root { + font-family: Arial, sans-serif; + background: #333; +} + + +#gridcontainer +{ + width: 800px; + line-height: 0; + clear: both; +} + +.griditem, .palette +{ + display: inline-block; + width: 70px; + height: 70px; + margin-left: 2px; + margin-bottom: 6px; + background: #AAA; + border: 1px solid black; +} + +.palette { + + border-radius: 50%; + margin-left: 20px; + margin-top: 30px; + border: 2px solid black; + +} + +#current-palette { + + width: 90px; + height: 90px; + float: right; + margin: 20px 60px 30px; + border: 2px solid black; + +} + + +#palettes { + +float: left; + +} diff --git a/100_blocks.js b/templates/100_blocks.html similarity index 51% rename from 100_blocks.js rename to templates/100_blocks.html index b8b46ec..2435950 100644 --- a/100_blocks.js +++ b/templates/100_blocks.html @@ -1,3 +1,20 @@ + + + + + + + + + +
+
+
+ + + + +