-
Notifications
You must be signed in to change notification settings - Fork 0
/
router.py
30 lines (23 loc) · 889 Bytes
/
router.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
from flask import render_template, request, redirect, session
from settings import app
from repositories.user import UserRepository
from twitterApp import TwitterApp
twitterApp = TwitterApp()
user = UserRepository()
@app.route('/', methods=['GET'])
def index():
if session.keys() >= {'access_token', 'access_token_secret'}:
return render_template("set_uid.html")
redirect_url = twitterApp.get_request_token()
return render_template("index.html", redirect_url=redirect_url)
@app.route('/', methods=['POST'])
def add_user():
uid = request.form.get('uid')
access_token = session['access_token']
access_token_secret = session['access_token_secret']
user.add(uid, access_token, access_token_secret)
return render_template("success.html")
@ app.route('/callback', methods=['GET'])
def callback():
twitterApp.callback()
return redirect('/')