-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
52 lines (33 loc) · 1 KB
/
main.py
File metadata and controls
52 lines (33 loc) · 1 KB
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# -*- encoding: utf-8 -*-
# coding: utf-8
# import os
__author__ = 'miyatake_y'
import bottle
import jinja2
import secret
import Twitter
from bottle import route, post, request, run
from bottle import TEMPLATE_PATH, jinja2_template as template
TEMPLATE_PATH.append("./template")
global twitter_
twitter_=None
def HomeHandler():
global twitter_
return template("home.j2", posts=twitter_.home_timeline())
# TODO: Method指定する
# とりあえずはログインは自動
@route('/')
def HomeHandler_():
return HomeHandler()
@post('/1/twitter/post')
def UpdateHandler_():
global twitter_
msg = request.forms.decode().get('status')
print("post:"+msg)
res = twitter_.update(msg)
return HomeHandler()
twitter_ = Twitter.Twitter(secret.consumer_key, secret.consumer_secret, secret.access_token, secret.access_token_secret)
if __name__ == "__main__":
run(host='localhost', port=1046, debug=True, reloader=True)
# if os.environ.get('BOTTLE_CHILD'):
print("child")