from flask import Flask, jsonify from dbtools import get_cursor, fetch_image_db, count_db app = Flask(__name__) c = get_cursor() #@app.route('/<category>') #def count(category, number): # return jsonify({'total': count_db(c, category)}) @app.route('/<category>/<int:number>') def image(category, number): r = list(fetch_image_db(c, category, number)[0])+[0]*4 print r return jsonify({'results': { 'category': r[0], 'gender': r[1], 'color': r[2], 'phototype': r[3], 'filename': r[4], 'thumbname': r[5], 'loc': r[6], 'description': r[7], 'price': r[8] }, 'total': count_db(c, category)[0][0]}) if __name__ == '__main__': app.run(host='0.0.0.0') #app.run(debug=True)
import smtplib import dbtools # Have the assets include properly for the HTML files by setting # the static_folder for flask. ASSETS_DIR = os.path.join(os.path.dirname(os.path.abspath(__file__)), "../flask/assets") print ASSETS_DIR app = Flask(__name__, template_folder=ASSETS_DIR, static_folder=ASSETS_DIR) SMTP_SERVER = "smtp.gmail.com" SMTP_PORT = 587 sender = "*****@*****.**" js_maxval = 9007199254740991 c = dbtools.get_cursor() ### # Helper functions ### def valid_schedule(json): # TODO: write a real validator if True: return True return False def secure_hash(d): # herp... return hash(d)