if row == None: db.close() return alreadyHandled row = dict(row) if not row['attachments']: attachments = {} else: attachments = json.loads(row['attachments']) if not attachments: attachments = {} filename = photos.uid(30)+ext attachments['raw_file'] = filename attachments = json.dumps(attachments) db.execute('UPDATE photos SET attachments = :attachments WHERE id=:id', {'attachments': attachments, 'id': row['id']}) if not storages.save(file, str(row['id'])+'_'+filename, type='attachment'): db.rollback() return alreadyHandled return {'id':row['id'],'attachments':{'raw_file': storages.url(str(row['id'])+'_'+filename, type='attachment')}} add_hook('handle_file_upload', handle_raw_files)
from picapi.plugins import add_hook from picapi.app import app, success import bottle def validate_echo(value, request, **kwargs): if request.route.rule == '/echo/<message>': return True, True if bottle.local.user: print(bottle.local.user) bottle.response.set_header('Access-Control-Allow-Origin', '*') #set the website public return True, True add_hook('filter_request_validation', validate_echo) @app.route('/echo/<message>') def echo(message): return success({'message':message}) @app.route('/info') def echo(): return success({"config":{"version":"030003","thumbQuality":"90","checkForUpdates":"1","sortingPhotos":"ORDER BY takestamp DESC","sortingAlbums":"ORDER BY id DESC","medium":"1","imagick":"1","dropboxKey":"","skipDuplicates":"0","plugins":"","location":"/home/bramas/Lychee/","login":true},"status":2})
else: attachments = json.loads(row['attachments']) if not attachments: attachments = {} filename = photos.uid(30) + ext attachments['raw_file'] = filename attachments = json.dumps(attachments) db.execute('UPDATE photos SET attachments = :attachments WHERE id=:id', { 'attachments': attachments, 'id': row['id'] }) if not storages.save( file, str(row['id']) + '_' + filename, type='attachment'): db.rollback() return alreadyHandled return { 'id': row['id'], 'attachments': { 'raw_file': storages.url(str(row['id']) + '_' + filename, type='attachment') } } add_hook('handle_file_upload', handle_raw_files)