This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def hello_world(): | |
print "hello world!" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DROP TABLE IF EXISTS dim_events; | |
CREATE TABLE dim_events ( | |
id INTEGER PRIMARY KEY AUTOINCREMENT, | |
date DATETIME, | |
duration REAL, | |
event_name TEXT | |
); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@webapp.route('/events/all', methods=['GET']) | |
def show_all_events(): | |
db = sqlite3.connect("dim_events.sqlite3") | |
cur = db.execute('select * from dim_events') | |
rows = cur.fetchall() | |
return render_template('events.html', rows = rows) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from flask.ext.sqlalchemy import SQLAlchemy | |
from sqlalchemy import Column, Integer, String, Date, Float | |
db = SQLAlchemy() | |
class Events(db.Model): | |
__tablename__ = 'events_full' | |
id = Column(Integer, primary_key=True) | |
date = Column(Date) | |
duration = Column(Float) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@webapp.route('/dbdisplay') | |
def display(): | |
return render_template("dbdisplay.html", | |
events = Events.query.all()) | |
@webapp.route('/dbdisplay/<event_type>') | |
def display_by_event_type(event_type): | |
return render_template("dbdisplay.html", | |
events = (Events.query | |
.filter_by(event_type = event_type) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@webapp.route('/user') | |
def user(): | |
user_dict = {'first': 'Robert', 'last': 'Chang', 'twitter_handle': '@_rchang'} | |
return render_template("user.html", user = user_dict) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@webapp.route('/user') | |
def user(): | |
user_dict = {'first': 'Robert', 'last': 'Chang', 'twitter_handle': '@_rchang'} | |
return render_template("user.html", user = user_dict) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@webapp.route('/user') | |
def user(): | |
user_dict = {'first': 'Robert', 'last': 'Chang', 'twitter_handle': '@_rchang'} | |
html = """ | |
<table border=1> | |
<tr> | |
<td>{first}</td> | |
<td>{last}</td> | |
<td>{twitter_handle}</td> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% extends "base.html" %} | |
{% block title %} User's Page {% endblock %} | |
{% block content %} | |
<h1> User </h1> | |
<table border=1> | |
<tbody> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@webapp.route('/', methods = ['GET', 'POST']) | |
def hello_world(): | |
if request.method == 'POST': | |
return 'Hello World!' + request.form.get('username', '') | |
else: | |
return 'Hello World Anonymous!' |
OlderNewer