This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
import tweepy | |
import json | |
from datetime import timezone, timedelta | |
import datetime | |
consumer_key = '' | |
consumer_secret = '' | |
access_token = '' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import tweepy | |
import json | |
from datetime import timezone | |
import datetime | |
response = requests.get('https://scanmap.frnsys.com/NY/log') | |
json_data = json.loads(response.text) | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from bs4 import BeautifulSoup | |
import requests | |
r = requests.get("http://www.metmuseum.org/collection/the-collection-online/search/36484") | |
bs = BeautifulSoup(r.content) | |
imgs = bs.findAll('img', src=True) | |
for img in imgs: | |
print img['src'] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% extends "main.html" %} | |
{% autoescape None %} | |
{% block body %} | |
{% for news_item in news%} | |
<p> | |
<b>{{str(news_item['datetime_added'])}}</b> | |
</p> | |
<p> | |
{{ news_item.get('text', '') }} | |
</p> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#news handler, pulls news from mongodb, renders news page | |
class NewsHandler (tornado.web.RequestHandler): | |
def get(self, currentPage): | |
news_content = dict() | |
coll = self.application.db.news | |
news = coll.find().sort("_id", DESCENDING) | |
#pagination code | |
currentPage = int(currentPage) | |
newsItemsPerPage = 2 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MP3UploadHandler(tornado.web.RequestHandler): | |
def get(self): | |
self.render('mp3upload.html') | |
def post(self): | |
mp3=self.request.files['mp3'][0] #mp3 post data from form | |
mp3body=mp3['body'] #body of mp3 file | |
mp3name = mp3['filename'] #mp3 name and path | |
conn = S3Connection('AWS_ACCESS_KEY_ID','AWS_SECRET_ACCESS_KEY') #amazon s3 connection | |
bucket = conn.create_bucket('foundsound_mp3') #bucket for images |