Skip to content


Subversion checkout URL

You can clone with
Download ZIP
tree: 986c92377a
Fetching contributors…

Cannot retrieve contributors at this time

55 lines (40 sloc) 1.241 kb
import random
import os
from flask import Flask, jsonify, request
from images import images
app = Flask(__name__)
app.debug = True
# The number of idols we drop by default.
def index():
d = {
'resources': {
'/random': 'A random picture of a Japanese idol.',
'/bomb(?count=5)': 'Bomb idols. Optionally, set how many you\'d like to bomb.',
'/count': 'The number of idols we have.'
'source': '',
'thanks': [
return jsonify(d)
def random_idol():
idol = random.choice(images)
return jsonify({'idol': idol})
def bomb_idols():
count = request.args.get('count', DEFAULT_BOMB)
idols = random.sample(images, int(count))
return jsonify({'idols': idols})
def count_idols():
count = len(images)
return jsonify({'count': count})
if __name__ == '__main__':
# Bind to PORT if defined, otherwise default to 5000.
port = int(os.environ.get('PORT', 5000))'', port=port)
Jump to Line
Something went wrong with that request. Please try again.