def main(): models.initModels() xmpp_conn = timebot.Connection(config.CONF_GMAIL_LOGIN, config.CONF_GMAIL_PASS) if not xmpp_conn.connect(): exit(2) bot = timebot.Timebot(xmpp_conn) socklist = [xmpp_conn.getSock()] while True: (i, o, e) = select.select(socklist, [], [], 2) if not i: continue for sock in i: if sock == xmpp_conn.getSock(): xmpp_conn.client.Process(1)
if request.method == 'POST': fileName = secure_filename(urlparse.unquote(request.headers['X-File-Name'])) if allowed_file(fileName): filePath = os.path.join(app.config['UPLOAD_FOLDER'], fileName) with open(filePath, 'w') as fd: fd.write(request.data) # delete existing header dbSession.query(ImageTag).filter(ImageTag.tag == "header").delete() tag = ImageTag(hash=md5(filePath), tag='header', path=fileName) dbSession.add(tag) dbSession.commit() return 'done' else: imageTag = dbSession.query(ImageTag).filter(ImageTag.tag == "header").first() data = { 'url' : _getHeaderUrl() } return flask.jsonify(**data) # Custom static data @app.route('/uploads/<path:filename>') def custom_static(filename): return send_from_directory(app.config['UPLOAD_FOLDER'], filename) if __name__ == '__main__': initModels() app.run(host='0.0.0.0')