Skip to content

Instantly share code, notes, and snippets.

@rtuita23
rtuita23 / tbay.py
Created February 1, 2015 00:36
tbay
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker
from sqlalchemy.ext.declarative import declarative_base
from datetime import datetime
from sqlalchemy import Column, Integer, String, DateTime
engine = create_engine('postgresql://action:action@localhost:5432/tbay')
Session = sessionmaker(bind=engine)
session = Session()
Base = declarative_base()
jinja2.exceptions.TemplateSyntaxError
TemplateSyntaxError: expected token 'as', got 'with'
Traceback (most recent call last)
File "/home/action/thinkful/projects/jinja_example/env/lib/python2.7/site-packages/flask/app.py", line 1836, in __call__
return self.wsgi_app(environ, start_response)
File "/home/action/thinkful/projects/jinja_example/env/lib/python2.7/site-packages/flask/app.py", line 1820, in wsgi_app
response = self.make_response(self.handle_exception(e))
File "/home/action/thinkful/projects/jinja_example/env/lib/python2.7/site-packages/flask/app.py", line 1403, in handle_exception
reraise(exc_type, exc_value, tb)
@rtuita23
rtuita23 / base.html
Created February 16, 2015 04:37
base.html
{% from "macros.html" import nav_link with context %}
<!DOCTYPE html>
<html>
<head>
<title>Flask Template Example</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style>
div#main {
max-width: 500px;
padding: 20px;
@rtuita23
rtuita23 / macros.html
Created February 16, 2015 04:38
macros
{% macro nav_link(endpoint, name) %}
{% if request.endpoint.endswith(endpoint) %}
<a href="{{ url_for(endpoint) }}" class="active">{{name}}</a>
{% else %}
<a href="{{ url_for(endpoint) }}">{{name}}</a>
{% endif %}
{% endmacro %}
@rtuita23
rtuita23 / template.html
Created February 16, 2015 04:39
Template
<!DOCTYPE html>
<html>
<head>
<title>Flask Template Example</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style>
div#main {
max-width: 500px;
padding: 20px;
}
@rtuita23
rtuita23 / run.py
Created February 16, 2015 04:40
Run
from flask import Flask, render_template
from datetime import datetime
app = Flask(__name__)
@app.route('/')
def template_test():
return render_template('template.html', my_string='Wheeeee!', my_list=[0,1,2,3,4,5])
@app.route("/home")
werkzeug.routing.BuildError
BuildError: ('about', {}, None)
Traceback (most recent call last)
File "/home/action/thinkful/projects/jinja_example/env/lib/python2.7/site-packages/flask/app.py", line 1836, in __call__
return self.wsgi_app(environ, start_response)
File "/home/action/thinkful/projects/jinja_example/env/lib/python2.7/site-packages/flask/app.py", line 1820, in wsgi_app
response = self.make_response(self.handle_exception(e))
File "/home/action/thinkful/projects/jinja_example/env/lib/python2.7/site-packages/flask/app.py", line 1403, in handle_exception
reraise(exc_type, exc_value, tb)
@rtuita23
rtuita23 / locudata.py
Created April 20, 2016 17:09
using dev.loc.com api to build a simple api call from python
import urllib2
import json
url = 'https://api.locu.com/v1_0/venue/search/?locality=lake%20stevens&api_key=9cec4ffbd2988adb04dfdd6ed07e97278861c476'
json_obj = urllib2.urlopen(url)
data = json.load(json_obj)
print data['objects'][2]