Пример #1
0
def main():
    logger.info("Starting google music uploader")
    pidfile = None
    if len(sys.argv) > 1:
        if sys.argv[1] == "--pidfile":
            if len(sys.argv) < 3:
                logger.error("Missing pidfile path")
                return
            pidfile = sys.argv[2]

    if pidfile:
        if not util.make_sure_path_exists(os.path.dirname(pidfile)):
            logger.warning("Error creating pidfile directory %s" % os.path.dirname(pidfile))
            return
        with open(pidfile, "w+") as f:
            logger.debug("Writing pidfile to %s" % pidfile)
            f.write(str(os.getpid()))
    config = util.read_config(DirInfo.AppConfig)

    session_opts = {
        'session.type': 'memory',
        'session.auto': 'true'
    }
    app = SessionMiddleware(bottle.app(), session_opts)

    run(app=app, host='0.0.0.0', port=config['PORT'], debug=True)
Пример #2
0
def run_http():
    try:
        # run(host="0.0.0.0", port=port)
        run(server="paste", host="0.0.0.0", port=port)
    except Exception, e:
        log.error("Error while exec: %s", e.message)
        log.exception("Exeption while exec: ")
        time.sleep(10)
        http_thread = threading.Thread(target=run_http)
        http_thread.setDaemon(True)
        http_thread.start()
Пример #3
0
# -*- coding: utf-8 -*-

import sys
sys.path.append('libs')

from app import app


# ==========================================
#   add static path
# ==========================================
@route('/stat/<filepath:path>')
def server_static(filepath):
	return static_file(filepath, root='./app/static')

# ==========================================
# run only in bottle
# ==========================================
from bottle.bottle import debug, run

debug(True)
if __name__ == '__main__':
    port = int(os.environ.get("PORT", 8080))
    run(app, reloader=True, host='0.0.0.0', port=port)

# ==========================================
# run in gunicorn
# ==========================================
#app = default_app()
Пример #4
0
    else:
        print "Invalid username or password"
        return bottle.template("login", dict(username=cgi.escape(username), password="",
                                        login_error="Invalid Login"))

@bottle.get("/welcome")
def present_welcome():
    return bottle.template("welcome", {'username': '******'})

    
#def main():
#    debug(True)
#    run_wsgi_app(bottle.default_app())


@bottle.error(403)
def Error403(code):
    return 'Wrong Coding. Check it now!'


@bottle.error(404)
def Error404(code):
    return 'Wrong place to search'

#if __name__=="__main__":
#    main()
bottle.debug(True)
bottle.run(host='localhost', port=3002)  
#bottle.run(server='gae')         # Start the webserver running and wait for requests
#app = bottle.app()
Пример #5
0
        if not USER_RE.match(username):
            errors['username_error'] = "invalid username. try just letters and numbers"
            return False

        if not PASS_RE.match(password):
            errors['password_error'] = "invalid password."
            return False
        if password != verify:
            errors['verify_error'] = "password must match"
            return False
        if email != "":
            if not EMAIL_RE.match(email):
                errors['email_error'] = "invalid email address"
                return False
        return True

    connection_string = "mongodb://localhost"
    connection = pymongo.MongoClient(connection_string)
    database = connection.blogging

    posts = blogPostDAO.BlogPostDAO(database)
    users = userDAO.UserDAO(database)
    sessions = sessionDAO.SessionDAO(database)


bottle.debug(True)
bottle.run(host='localhost', port='3002') 
#bottle.run(server='gae')         # Start the webserver running and wait for requests
#app = bottle.app()
Пример #6
0
def main():
    run(host='localhost', port=9001)
Пример #7
0
def root_post():
    mac    = request.json['mac']
    state  = request.json['state']
    
    mac    = [int(b,16) for b in mac.split('-')]
    
    manager.dn_sendData(
        macAddress      = mac,
        priority        = 1,
        srcPort         = 0xf0b9,
        dstPort         = 0xf0b9,
        options         = 0,
        data            = [
            0x05,            # un-ACK'ed transport, resync connection
            0x00,            # seqnum and session
            0x02,            # "PUT" command
            0xff,            # ==TLV== address (0xff)
            0x02,            #         length (2)
            0x03,            #         digital_out (3)
            0x02,            #         Actuate LED (2)
            0x00,            # ==TLV== Value (0x00)
            0x01,            #         length (1)
            state,           # set pin high or low
        ]
    )
    
    sys.stdout.write('.')

print 'ok. JSON server started on port 8080'
run(host='localhost', port=8080, quiet=True)
Пример #8
0
Файл: app.py Проект: dexta/jabol
	toLoad="var inception=["	
	for dirList in os.listdir("./links/"):
		if(len(re.findall("\.js$",dirList))==0): continue
		toLoad += "{typ:\"js\",path:\"links/%s\"},\n"%dirList
	toLoad=toLoad[:-2]
	toLoad+="];\n"

	out = "%s\n %s"%(data,toLoad)
	response.content_type = "text/javascript"
	return out

@route('/js/<filename>')
def javascript(filename):
	return static_file(filename, root="./js/",mimetype="text/javascript")

@route('/links/<filename>')
def linkmagic(filename):
	return static_file(filename, root="./links/",mimetype="text/javascript")

@route('/css/<filename>')
def stylesheet(filename):
	return static_file(filename, root="./css/",mimetype="text/css")

@route('/')
def default():
	return static_file("aRlinks.html", root='./', mimetype='text/html')


run(host='localhost', port=8080, reloader=True)
Пример #9
0
    id_list = "("
    for k in page_id_list:
        id_list += "%s,"%k
    id_list = id_list.strip(",") + ")"
    conn = sqlite3.connect(data5.db)
    c = conn.cursor()
    sql = "select * " \
          + "from page_info  " \
          + "where id in " + id_list + ";"
    res = c.execute(sql)
    res = [r for r in res]
    return res
def get_page_id_list_from_key_word_cut(cut):
    keyword = "("
    for k in cut:
        if k == " ":
            continue
        keyword += "'%s',"%k
    keyword = keyword.strip(",") + ")"
    conn = sqlite3.connect(data5.db)
    c = conn.cursor()
    sql = "select page_id " \
          + "from page_index  " \
          + "where keyword in " + keyword + ";"
    res = c.execute(sql)
    res = [r[0] for r in res]
    return res

if __name__ == '__main__':
    bottle.run(application=APP)
Пример #10
0
import json
from bottle.bottle import route, run, Bottle

app = Bottle()


@app.route('/')
@app.route('/hello')
@app.route('/hello/<name>')
def hello(name='world'):
    return 'hello %s!' % (name,)


@app.route('/jobs/<offset:int>/<size:int>')
def get_jobs(offset, size):
    d = {"offset": offset, "size": size}
    return json.dumps(d)


run(app,host='localhost', port=8080, debug=True)

Пример #11
0
        errors['email_error'] = ""

        if not USER_RE.match(username):
            errors['username_error'] = "invalid username. try just letters and numbers"
            return False

        if not PASS_RE.match(password):
            errors['password_error'] = "invalid password."
            return False
        if password != verify:
            errors['verify_error'] = "password must match"
            return False
        if email != "":
            if not EMAIL_RE.match(email):
                errors['email_error'] = "invalid email address"
                return False
        return True

    connection_string = "mongodb://localhost"
    connection = pymongo.MongoClient(connection_string)
    database = connection.blogging

    posts = blogPostDAO.BlogPostDAO(database)
    users = userDAO.UserDAO(database)
    sessions = sessionDAO.SessionDAO(database)


bottle.debug(True)
bottle.run(server='gae')         # Start the webserver running and wait for requests
app = bottle.app()
Пример #12
0
poe = Poebot(cfg.log_file)
poe.set_command(cfg.speech_command)

@route('/static/<filepath:path>')
def static(filepath):
	return static_file(filepath, root=cfg.static_dir)

@route('/speak', method='POST')
def speak():
    post_data = json.load(request.body)
    if 'new_color' in post_data:
        new_color = True
    else:
        new_color = False
    try:
        user_color = poe.talk(post_data['message'], request.remote_addr, new_color=new_color)
    except OSError:
        response.status = "420 Chill out man"
        return '#FF0000'
    return user_color

@route('/about')
def about():
    return template('about')

@route('/')
def index():
    return template('index')

run(host=cfg.addr, port=cfg.port)
Пример #13
0
def root_post():
    mac = request.json['mac']
    state = request.json['state']

    mac = [int(b, 16) for b in mac.split('-')]

    manager.dn_sendData(
        macAddress=mac,
        priority=1,
        srcPort=0xf0b9,
        dstPort=0xf0b9,
        options=0,
        data=[
            0x05,  # un-ACK'ed transport, resync connection
            0x00,  # seqnum and session
            0x02,  # "PUT" command
            0xff,  # ==TLV== address (0xff)
            0x02,  #         length (2)
            0x03,  #         digital_out (3)
            0x02,  #         Actuate LED (2)
            0x00,  # ==TLV== Value (0x00)
            0x01,  #         length (1)
            state,  # set pin high or low
        ])

    sys.stdout.write('.')


print 'ok. JSON server started on port 8080'
run(host='localhost', port=8080, quiet=True)
Пример #14
0
	return "jdownloader=true; var version='17461';"

@bottle.route('/flash/addcrypted2', method = 'post')
def clicknload2():
	password = bottle.request.forms.get("passwords")
	source = bottle.request.forms.get("source")
	jk = bottle.request.forms.get("jk")
	crypted = bottle.request.forms.get("crypted")

	urls = decrypt_clicknload2(crypted, jk)
	for u in urls: print(u)

def decrypt_clicknload2(eaw_crypted, raw_jk):
	decrypt = aes_decrypt(eaw_crypted, extract_jk(raw_jk))
	return get_urls(decrypt)

def get_urls(enc_crypt):
	return [result for result in enc_crypt.decode("utf-8").replace('\x00', '').split("\r\n") if len(result) > 0]

def extract_jk(jk):
	i1 = jk.index("'") + 1
	i2 = jk.index("'", i1)
	return base64.b16decode(jk[i1:i2])

def aes_decrypt(enc, key):
	cipher = AES.new(key, AES.MODE_CBC, key)
	return cipher.decrypt(base64.b64decode(enc))

if __name__ == "__main__":
	bottle.run(host='127.0.0.1', port=9666, debug=False)
Пример #15
0
        if not USER_RE.match(username):
            errors[
                'username_error'] = "invalid username. try just letters and numbers"
            return False

        if not PASS_RE.match(password):
            errors['password_error'] = "invalid password."
            return False
        if password != verify:
            errors['verify_error'] = "password must match"
            return False
        if email != "":
            if not EMAIL_RE.match(email):
                errors['email_error'] = "invalid email address"
                return False
        return True

    connection_string = "mongodb://localhost"
    connection = pymongo.MongoClient(connection_string)
    database = connection.blogging

    posts = blogPostDAO.BlogPostDAO(database)
    users = userDAO.UserDAO(database)
    sessions = sessionDAO.SessionDAO(database)


bottle.debug(True)
bottle.run(server='gae')  # Start the webserver running and wait for requests
app = bottle.app()
Пример #16
0
def main():
	run(host='localhost', port=8080)
Пример #17
0
def main(port_server):
    run(host='localhost', port=port_server, debug=True)