示例#1
0
def albums_edit_route():
	username = request.args.get('username')
	con = mysql.connection
	cur = con.cursor()
	if request.method == 'POST':
		if request.form['op'] == 'delete':
			cur.execute("DELETE FROM Album WHERE albumid = '%s'"%(request.form['albumid']))	
		if request.form['op'] == 'add':
			title = request.form['title']
			date = time.strftime('%Y-%m-%d', time.gmtime())
			sqlcode = "INSERT INTO Album (title, created, lastupdated, username) VALUES ('%s', '%s', '%s', '%s')" % (title, date, date, username)
			cur.execute(sqlcode)
			cur.execute("SELECT LAST_INSERT_ID()")
			id = cur.fetchall()
			con.commit()
			return redirect(appendKey("/album/edit?id=%d"%(id[0])))
	cur.execute("SELECT * FROM Album WHERE username ='******'"%(username))
	msgs = cur.fetchall()
	con.commit()
	options = {
		"edit": True
	}
	return render_template("albums.html", albums=msgs, username = username, **options)
示例#2
0
from flask import *
import hashlib
import os
import time

album = Blueprint('album', __name__, template_folder='views')

ALLOWED_EXTENSIONS = set(['png', 'jpg', 'bmp', 'gif'])
APP_ROOT = os.path.dirname(os.path.abspath(__file__))
UPLOAD_FOLDER = os.path.join(APP_ROOT, '../static/pictures')
def allowed_file(filename):
    lowerFileName = filename.lower()
    print 
    return '.' in lowerFileName and lowerFileName.rsplit('.', 1)[1] in ALLOWED_EXTENSIONS

@album.route(appendKey('/album/edit'), methods=['GET', 'POST'])
def album_edit_route():

    albumid = request.args.get('id')
    if not albumid:
        abort(404)
    con = mysql.connection
    cur = con.cursor()
    cur.execute("SELECT albumid FROM Album WHERE albumid=%s"%(albumid))
    album = cur.fetchall()
    if not album:
        abort(404)
    
    
    #add picture to static/pictures
    if request.method == 'POST':
示例#3
0
from utils import appendKey, mysql
from flask import *

pic = Blueprint('pic', __name__, template_folder='views')

@pic.route(appendKey('/pic'))
def pic_route():
	pic_id = request.args.get('id')
	cur = mysql.connection.cursor()
	cur.execute("SELECT url FROM Photo WHERE Photo.picid = '%s'" %(pic_id))
	msgs = cur.fetchall()
	cur.execute("SELECT albumid FROM Contain WHERE Contain.picid = '%s'" %(pic_id))
	msgs1 = cur.fetchall()
	options = {
		"url":msgs[0],
		"albumid":msgs1[0]
	}
	return render_template("pic.html", **options)
示例#4
0
from utils import appendKey, mysql, secretKey
from flask import *
# -*- coding: utf-8 -*-

main = Blueprint('main', __name__, template_folder='views')

@main.route(appendKey('/'))
def main_route():
	cur = mysql.connection.cursor()
	cur.execute("SELECT username FROM User")
	msgs = cur.fetchall()
	return render_template("index.html", usernames=msgs)