Permalink
Browse files

Adds a tiny little Web app.

  • Loading branch information...
jeremyjbowers committed Feb 28, 2013
1 parent 15a627a commit a63d129a3d9d8246334d3be0416c2c6c9b200264
View
@@ -0,0 +1,34 @@
+from flask import Flask, render_template
+
+from models import Bank
+
+app = Flask(__name__)
+
+
+@app.route('/', methods=['GET'])
+def failed_banks_list():
+
+ context = {
+ 'banks': Bank.select()
+ }
+
+ return render_template('list.html', **context)
+
+
+@app.route('/bank/<cert_num>/', methods=['GET'])
+def failed_bank_detail(cert_num):
+ this_bank = Bank.select()\
+ .where(Bank.cert_num == int(cert_num)).get()
+ same_state_banks = Bank.select()\
+ .where(Bank.state == this_bank.state)\
+ .where(Bank.cert_num != int(cert_num))
+
+ context = {
+ 'bank': this_bank,
+ 'same_state_banks': same_state_banks
+ }
+
+ return render_template('detail.html', **context)
+
+if __name__ == "__main__":
+ app.run(host='0.0.0.0', debug=True)
View
@@ -0,0 +1,18 @@
+from peewee import *
+
+db = SqliteDatabase('fdic.sqlite')
+
+
+class Bank(Model):
+ bank = CharField()
+ city = CharField()
+ state = CharField()
+ cert_num = PrimaryKeyField()
+ acq_inst = CharField()
+ closed = DateField()
+ updated = DateField()
+ url = CharField()
+
+ class Meta:
+ database = db
+ db_table = 'failed_banks'
@@ -1,2 +1,4 @@
beautifulsoup4
python-dateutil<=1.5
+flask-peewee
+flask
@@ -0,0 +1,13 @@
+<!DOCTYPE html>
+<html lang="en">
+ <head>
+ <link href="//netdna.bootstrapcdn.com/twitter-bootstrap/2.3.0/css/bootstrap-combined.min.css" rel="stylesheet">
+ </head>
+ <body>
+ <div class="container-fluid">
+ <div class="row-fluid">
+ <div class="span12">{% block content %}{% endblock %}</div>
+ </div>
+ </div>
+ </body>
+</html>
@@ -0,0 +1,18 @@
+{% extends 'base.html' %}
+
+{% block content %}
+ <h1>{{ bank.bank }}</h1>
+ <h2>{{ bank.city}}, {{ bank.state }}</h2>
+ <h4>Closed {{ bank.closed }}</h4>
+ <p>{{ bank.bank }} has the certification number {{ bank.cert_num }} and was closed on {{ bank.closed }}.
+ <br/>It was acquired by {{ bank.acq_inst }}.
+ <br/><a href="{{ bank.url }}">See this bank</a> on the FDIC Web site.</p>
+ {% if same_state_banks > 0 %}
+ <p><h2>{{ same_state_banks.count() }} more banks in {{ bank.state }}</h2>
+ <ul>{% for bank in same_state_banks %}
+ <li><a href="/bank/{{ bank.cert_num }}/">{{ bank.bank }}</a></li>
+ {% endfor %}</ul>
+ </p>
+ {% endif %}
+ <button class="btn btn-info"><i class="icon-circle-arrow-left icon-white"></i> Back</button>
+{% endblock %}
@@ -0,0 +1,9 @@
+{% extends 'base.html' %}
+
+{% block content %}
+ <h1>Failed banks</h1>
+ <ul>{% for bank in banks %}
+ <li><h4><a href="/bank/{{ bank.cert_num }}/">{{ bank.bank }}</a></h4>
+ {{ bank.city }}, {{ bank.state }}</li>
+ {% endfor %}</ul>
+{% endblock %}

0 comments on commit a63d129

Please sign in to comment.