Skip to content
This repository was archived by the owner on Jan 20, 2025. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .DS_Store
Binary file not shown.
6 changes: 6 additions & 0 deletions .ipynb_checkpoints/Build-checkpoint.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"cells": [],
"metadata": {},
"nbformat": 4,
"nbformat_minor": 0
}
33 changes: 33 additions & 0 deletions squawker/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<!DOCTYPE html>
<html>
<link rel="stylesheet" type="text/css" href="style.css"></style>
<head>
<title>Squawker</title>
</head>
<body>
<div class="addSquawk">
<form action="/" method="POST">
<div class="feed">
<text maxlength="140" id="feed" name="content" style="border:double 1px #984e00;"></text>
</div>

<div>
<button type="submit">Add Squawk</button>
</div>

</form>
</div>
<div class="seeSquawks">
<label for="allSquawks">SquawkFeed</label>
{% for squawk in allSquawks %}
<div class="sq">
<p>{{squawk[1]}}</p>
<p>{{squawk[2]}}</p>
</div>
{% endfor %}
</div>

</body>
</div>
</html>

7 changes: 5 additions & 2 deletions squawker/schema.sql
Original file line number Diff line number Diff line change
@@ -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);
18 changes: 13 additions & 5 deletions squawker/server.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from flask import Flask, g
from flask import Flask, g, abort, redirect, render_template, url_for, request
import sqlite3


Expand Down Expand Up @@ -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()
18 changes: 18 additions & 0 deletions squawker/style.css
Original file line number Diff line number Diff line change
@@ -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;
}

32 changes: 32 additions & 0 deletions squawker/templates/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<!DOCTYPE html>
<html>
<link rel="stylesheet" type="text/css" href="style.css"></style>
<head>
<title>Squawker</title>
</head>
<body>
<div class="addSquawk">
<form action="/" method="POST">
<div class="feed">
<text maxlength="140" id="feed" name="content" style="border:double 1px #984e00;"></text>
</div>

<div>
<button type="submit">Add Squawk</button>
</div>

</form>
</div>
<div class="seeSquawks">
<label for="allSquawks">SquawkFeed</label>
{% for squawk in allSquawks %}
<div class="sq">
<p>{{squawk[1]}}</p>
<p>{{squawk[2]}}</p>
</div>
{% endfor %}
</div>

</body>
</div>
</html>