Permalink
Browse files

linting

  • Loading branch information...
1 parent 19c9f37 commit 9d043aa218d538f50b080e18323d3f9729ff308e @ranman committed Mar 5, 2013
Showing with 15 additions and 11 deletions.
  1. +15 −11 main.py
View
@@ -1,41 +1,42 @@
-from flask import Flask, render_template, Response, request, redirect
+from flask import Flask, render_template, request, redirect
import foursquare
import yaml
-import logging
-import pprint
from dropbox import session, client
-logging.basicConfig()
-logger = logging.getLogger('foursquare')
-
_config = yaml.safe_load(file('config.yaml'))
app = Flask(__name__)
-redirect_uri = _config['flask']['base_url'] + _config['foursquare']['redirect_uri']
+redirect_uri = (_config['flask']['base_url'] +
+ _config['foursquare']['redirect_uri'])
foursqclient = foursquare.Foursquare(
client_id=_config['foursquare']['client_id'],
client_secret=_config['foursquare']['client_secret'],
redirect_uri=redirect_uri)
+# remove for prod
foursqclient.set_access_token(_config['foursquare']['access_token'])
dbox_session = session.DropboxSession(_config['dropbox']['app_key'],
_config['dropbox']['app_secret'],
_config['dropbox']['access_type'])
+# remove for prod
dbox_session.set_token(_config['dropbox']['access_token_key'],
_config['dropbox']['access_token_secret'])
+
@app.route('/dropbox/auth')
def dropbox_auth():
- redirect_uri = _config['flask']['base_url'] + _config['dropbox']['redirect_uri']
+ redirect_uri = (_config['flask']['base_url'] +
+ _config['dropbox']['redirect_uri'])
url = dbox_session.build_authorize_url(
dbox_session.obtain_request_token(),
oauth_callback=redirect_uri)
return redirect(url, 302)
+
@app.route(_config['dropbox']['redirect_uri'])
def dropbox_oath():
access_token = dbox_session.obtain_access_token(
@@ -44,10 +45,10 @@ def dropbox_oath():
access_token.secret)
return redirect(_config['flask']['base_url'], 302)
+
@app.route(_config['foursquare']['redirect_uri'])
def foursquare_oauth():
access_token = foursqclient.oauth.get_token(request.args.get('code'))
- print access_token
# db store foursq access token
foursqclient.set_access_token(access_token)
return redirect(_config['flask']['base_url'], 302)
@@ -61,11 +62,14 @@ def foursquare_auth():
@app.route('/')
def main_page():
- checkin = foursqclient.users.checkins(params={'limit': 1})['checkins']['items'][0]
+ checkin = foursqclient.users.checkins(params={'limit': 1})
+ checkin = checkin['checkins']['items'][0]
dbox_client = client.DropboxClient(dbox_session)
latest_photo = dbox_client.metadata('/.gitshots')['contents'][-1]
latest_photo = dbox_client.media(latest_photo['path'])['url']
- return render_template('index.html', checkin=checkin, latest_photo=latest_photo)
+ return render_template('index.html',
+ checkin=checkin,
+ latest_photo=latest_photo)
if __name__ == '__main__':
app.debug = _config['flask']['debug']

0 comments on commit 9d043aa

Please sign in to comment.