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
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Hello World!</title> | |
</head> | |
<body> | |
<p> | |
Welcome {{username}} | |
<p> | |
<ul> |
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 bottle | |
@bottle.route('/') | |
def home_page(): | |
mythings = ['apple', 'orange', 'banana', 'peach'] | |
return bottle.template('hello_world2', {'username':'Masanori', | |
'things':mythings}) | |
@bottle.post('/favorite_fruit') | |
def favorite_fruit(): | |
fruit = bottle.request.forms.get('fruit') |
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Hello World!</title> | |
</head> | |
<body> | |
<p> | |
Welcome {{username}} | |
<p> | |
<ul> |
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Fruit Selection Confirmation</title> | |
</head> | |
<body> | |
<p> | |
Your favorite fruit is {{fruit}} | |
</body> | |
</html> |
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 bottle | |
@bottle.route('/') | |
def home_page(): | |
mythings = ['apple', 'orange', 'banana', 'peach'] | |
return bottle.template('hello_world2', {'username':'Masanori', | |
'things':mythings}) | |
@bottle.post('/favorite_fruit') | |
def favorite_fruit(): | |
fruit = bottle.request.forms.get('fruit') |
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
use school | |
var types = ['exam', 'homework', 'quiz'] | |
for (student_id = 0; student_id < 100; student_id++) { | |
for (type=0; type < 3; type++) { | |
var r = {'student_id':student_id, | |
'type':types[type], | |
'score':Math.random() * 100}; | |
db.scores.insert(r) | |
} |
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 pymongo | |
import sys | |
connection = pymongo.MongoClient("mongodb://localhost") | |
db = connection.school | |
scores = db.scores | |
def find(): | |
query = {'type': 'exam'} | |
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 pymongo | |
import sys | |
connection = pymongo.MongoClient("mongodb://localhost") | |
db = connection.school | |
scores = db.scores | |
def find(): | |
query = {'type': 'exam'} | |
selector = {'student_id': 1, '_id': 0} |
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 pymongo | |
import sys | |
connection = pymongo.MongoClient("mongodb://localhost") | |
db = connection.school | |
scores = db.scores | |
def find(): | |
query = {'type': 'exam', 'score':{'$gt':50, '$lt':70}} | |
selector = {'student_id': 1, 'score':1, '_id': 0} |
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 json | |
from urllib.request import urlopen | |
import pymongo | |
connection = pymongo.MongoClient("mongodb://localhost") | |
db = connection.reddit | |
stories = db.stories | |
reddit_page = urlopen('http://www.reddit.com/r/Python/.json') |