diff --git a/index.html b/index.html
new file mode 100644
index 0000000..4d58590
--- /dev/null
+++ b/index.html
@@ -0,0 +1,62 @@
+
+
+
+ Squawker Nation
+
+
+
+
+
+
+
+
+
+
+ {% block content %}
+
Trending on Squawker
+
+ {% for sqk in squawks %}
+
+ {% else %}
+
+
+ {% endfor %}
+
+
+
+
+
\ No newline at end of file
diff --git a/schema.sql b/schema.sql
new file mode 100644
index 0000000..6471ad5
--- /dev/null
+++ b/schema.sql
@@ -0,0 +1,7 @@
+DROP TABLE IF EXISTS squawks;
+CREATE TABLE squawks (
+ id INTEGER PRIMARY KEY AUTOINCREMENT,
+ squawk VARCHAR(140) DEFAULT NULL,
+ ts TIMESTAMP DEFAULT CURRENT_TIMESTAMP
+);
+
diff --git a/squawker/__pycache__/__init__.cpython-35.pyc b/squawker/__pycache__/__init__.cpython-35.pyc
new file mode 100644
index 0000000..a9947d7
Binary files /dev/null and b/squawker/__pycache__/__init__.cpython-35.pyc differ
diff --git a/squawker/__pycache__/server.cpython-35.pyc b/squawker/__pycache__/server.cpython-35.pyc
new file mode 100644
index 0000000..9a19a09
Binary files /dev/null and b/squawker/__pycache__/server.cpython-35.pyc differ
diff --git a/squawker/schema.sql b/squawker/schema.sql
index 5e67ffb..6471ad5 100644
--- a/squawker/schema.sql
+++ b/squawker/schema.sql
@@ -1,3 +1,7 @@
--- 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,
+ squawk VARCHAR(140) DEFAULT NULL,
+ ts TIMESTAMP DEFAULT CURRENT_TIMESTAMP
+);
+
diff --git a/squawker/server.py b/squawker/server.py
index 6ff24ba..ca23bfe 100644
--- a/squawker/server.py
+++ b/squawker/server.py
@@ -1,11 +1,10 @@
-from flask import Flask, g
+from flask import Flask, g, request, render_template, abort
import sqlite3
-
+import datetime
# -- leave these lines intact --
app = Flask(__name__)
-
def get_db():
if not hasattr(g, 'sqlite_db'):
db_name = app.config.get('DATABASE', 'squawker.db')
@@ -34,15 +33,25 @@ def close_connection(exception):
db = getattr(g, 'sqlite_db', None)
if db is not None:
db.close()
-# ------------------------------
+# -------------------------------
-
-@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":
+ newS = request.form["msg"]
+ if len(newS) <= 140:
+ cur.execute("INSERT INTO squawks (squawk) VALUES (?)", [newS])
+ conn.commit()
+ else:
+ abort(400)
+
+ sel = cur.execute("SELECT * FROM squawks ORDER BY ts DESC")
+ allS = sel.fetchall()
+ conn.close()
+ return render_template("index.html", squawks=allS)
if __name__ == '__main__':
+ app.debug = True
app.run()
diff --git a/squawker/templates/index.html b/squawker/templates/index.html
new file mode 100644
index 0000000..83fe10e
--- /dev/null
+++ b/squawker/templates/index.html
@@ -0,0 +1,62 @@
+
+
+
+ Squawker Nation
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Trending on Squawker
+
+ {% for sqk in squawks %}
+
+
+ {% else %}
+
+
+ {% endfor %}
+
+
+
+
+
\ No newline at end of file
diff --git a/templates/index.html b/templates/index.html
new file mode 100644
index 0000000..83fe10e
--- /dev/null
+++ b/templates/index.html
@@ -0,0 +1,62 @@
+
+
+
+ Squawker Nation
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Trending on Squawker
+
+ {% for sqk in squawks %}
+
+
+ {% else %}
+
+
+ {% endfor %}
+
+
+
+
+
\ No newline at end of file