def add_tweet(tweet_info): lat = None lng = None if tweet_info['coordinates']: lat = float(tweet_info['coordinates']['coordinates'][0]) lng = float(tweet_info['coordinates']['coordinates'][1]) new_tweet = Tweet() new_tweet.uid = tweet_info['user']['id'] new_tweet.tid = tweet_info['id'] new_tweet.text = Thumbs.genThumbs(tweet_info['text']) if lat and lng: new_tweet.lat = lat new_tweet.lng = lng new_tweet.time = datetime.strptime(tweet_info['created_at'], "%a %b %d %H:%M:%S +0000 %Y") new_tweet.put()
def application(environ, start_response): start_response("200 OK", [("Content-Type", "text/plain")]) form = cgi.FieldStorage(fp=environ["wsgi.input"], environ=environ) tweets = Tweet.all() for i in tweets: i.delete() return "OK"
def application ( environ, start_response ): start_response('200 OK', [('Content-Type', 'text/plain')]) form = cgi.FieldStorage(fp=environ['wsgi.input'], environ=environ) tweets = Tweet.all() for i in tweets: i.delete() return "OK"
def add_tweet(tweet_info): if Tweet.isStored(tweet_info['id']): raise TweetAlreadyStoredException lat = None lng = None if tweet_info['coordinates']: lat = float(tweet_info['coordinates']['coordinates'][0]) lng = float(tweet_info['coordinates']['coordinates'][1]) new_tweet = Tweet() new_tweet.uid = tweet_info['user']['id'] new_tweet.tid = tweet_info['id'] new_tweet.text = tweet_info['text'] if lat and lng: new_tweet.lat = lat new_tweet.lng = lng new_tweet.time = datetime.strptime(tweet_info['created_at'], "%a %b %d %H:%M:%S +0000 %Y") new_tweet.put()
def application ( environ, start_response ): data = [] num_limit = 10 before_tid = None start_response('200 OK', [('Content-Type', 'text/plain')]) form = cgi.FieldStorage(fp=environ['wsgi.input'], environ=environ) if not form.has_key('account'): return json.dumps(data) if form.has_key('limit'): try: num_limit = int(form['limit'].value) except: pass if form.has_key('before_tid'): try: before_tid = int(form['before_tid'].value) except: pass account = form['account'].value user = User.get_user(account) if not user: return json.dumps(data) tweets = Tweet.getTweetsByUser(user, num_limit, before_tid) for tw in tweets: tw_data = [] tw_data.append(str(tw.time)) tw_data.append(Thumbs.genThumbs(tw.text)) if tw.lat and tw.lng: tw_data.append([tw.lng, tw.lat]) else: tw_data.append(None) tw_data.append(tw.tid) data.append(tw_data) return json.dumps(data)
def application(environ, start_response): start_response('200 OK', [('Content-Type', 'text/plain')]) form = cgi.FieldStorage(fp=environ['wsgi.input'], environ=environ) if not form.has_key('uid'): return "please input uid" if not form.has_key('tid'): return "please input tid" if not form.has_key('text'): return "please input text" if not form.has_key('lat'): return "please input lat" if not form.has_key('lng'): return "please input lng" tweet = Tweet() tweet.uid = int(form['uid'].value) tweet.tid = int(form['tid'].value) tweet.text = form['text'].value tweet.lat = float(form['lat'].value) tweet.lng = float(form['lng'].value) tweet.put() return "OK"
def application(environ, start_response): data = [] num_limit = 10 before_tid = None start_response('200 OK', [('Content-Type', 'text/plain')]) form = cgi.FieldStorage(fp=environ['wsgi.input'], environ=environ) if not form.has_key('account'): return json.dumps(data) if form.has_key('limit'): try: num_limit = int(form['limit'].value) except: pass if form.has_key('before_tid'): try: before_tid = int(form['before_tid'].value) except: pass account = form['account'].value user = User.get_user(account) if not user: return json.dumps(data) tweets = Tweet.getTweetsByUser(user, num_limit, before_tid) for tw in tweets: tw_data = [] tw_data.append(str(tw.time)) tw_data.append(Thumbs.genThumbs(tw.text)) if tw.lat and tw.lng: tw_data.append([tw.lng, tw.lat]) else: tw_data.append(None) tw_data.append(tw.tid) data.append(tw_data) return json.dumps(data)
def application(environ, start_response): start_response("200 OK", [("Content-Type", "text/plain")]) form = cgi.FieldStorage(fp=environ["wsgi.input"], environ=environ) if not form.has_key("uid"): return "please input uid" if not form.has_key("tid"): return "please input tid" if not form.has_key("text"): return "please input text" if not form.has_key("lat"): return "please input lat" if not form.has_key("lng"): return "please input lng" tweet = Tweet() tweet.uid = int(form["uid"].value) tweet.tid = int(form["tid"].value) tweet.text = form["text"].value tweet.lat = float(form["lat"].value) tweet.lng = float(form["lng"].value) tweet.put() return "OK"