diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000..dd6b545 Binary files /dev/null and b/.DS_Store differ diff --git a/.ipynb_checkpoints/Build-checkpoint.ipynb b/.ipynb_checkpoints/Build-checkpoint.ipynb new file mode 100644 index 0000000..286dcb3 --- /dev/null +++ b/.ipynb_checkpoints/Build-checkpoint.ipynb @@ -0,0 +1,6 @@ +{ + "cells": [], + "metadata": {}, + "nbformat": 4, + "nbformat_minor": 0 +} diff --git a/squawker/index.html b/squawker/index.html new file mode 100644 index 0000000..b72ecf7 --- /dev/null +++ b/squawker/index.html @@ -0,0 +1,33 @@ + + + + + Squawker + + +
+
+
+ +
+ +
+ +
+ +
+
+
+ + {% for squawk in allSquawks %} +
+

{{squawk[1]}}

+

{{squawk[2]}}

+
+ {% endfor %} +
+ + + + + diff --git a/squawker/schema.sql b/squawker/schema.sql index 5e67ffb..5214d12 100644 --- a/squawker/schema.sql +++ b/squawker/schema.sql @@ -1,3 +1,6 @@ -- TODO change this -DROP TABLE IF EXISTS mytable; -CREATE TABLE mytable (id integer); +DROP TABLE IF EXISTS squawks; +CREATE TABLE squawks ( + id INTEGER PRIMARY KEY AUTOINCREMENT, + post VARCHAR(140) NOT NULL, + createTime DATETIME DEFAULT CURRENT_TIMESTAMP); diff --git a/squawker/server.py b/squawker/server.py index 6ff24ba..a8ba456 100644 --- a/squawker/server.py +++ b/squawker/server.py @@ -1,4 +1,4 @@ -from flask import Flask, g +from flask import Flask, g, abort, redirect, render_template, url_for, request import sqlite3 @@ -37,12 +37,20 @@ def close_connection(exception): # ------------------------------ -@app.route('/') +@app.route('/', methods=["GET", "POST"]) def root(): conn = get_db() - # TODO change this - return "Hello World!" - + cur = conn.cursor() + if request.method == "POST": + addSquawk = request.form['content'] + if len(addSquawk) > 140: + abort(400) + else: + addition = conn.execute("INSERT INTO squawks (addSquawk) VALUES (?)", [addSquawk]) + conn.commit() + conn.execute("SELECT* FROM squawks ORDER BY createTime DESC") + listSq = cur.fetchall() + return render_template("index.html", allSquawks=listSq) if __name__ == '__main__': app.run() diff --git a/squawker/style.css b/squawker/style.css new file mode 100644 index 0000000..89cce90 --- /dev/null +++ b/squawker/style.css @@ -0,0 +1,18 @@ +div.addSquawk{ + background: #ffffff; + font-family: "Ariel" + font-size: 20px; +} + +div.seeSquawks{ + background: #ffffff; + font-family: "Ariel" + font-size: 20px; +} + +div.area{ + background: #ffffff; + font-family: "Ariel" + font-size: 20px; +} + diff --git a/squawker/templates/index.html b/squawker/templates/index.html new file mode 100644 index 0000000..e12bb75 --- /dev/null +++ b/squawker/templates/index.html @@ -0,0 +1,32 @@ + + + + + Squawker + + +
+
+
+ +
+ +
+ +
+ +
+
+
+ + {% for squawk in allSquawks %} +
+

{{squawk[1]}}

+

{{squawk[2]}}

+
+ {% endfor %} +
+ + + +