How to use the bottle.request.forms function in bottle

To help you get started, we’ve selected a few bottle examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github a2tm7a / SMARTHOME / Server / index.py View on Github external
@post('/fan_control')
def toggle():
	print "Hello Fan speed changed"
	status = request.forms.get('status')
	status = int(status)
	Interface = request.forms.get('Interface')
	print Interface
	condition_fan="INSERT INTO Fan(Status,Interface,Time) VALUES('%d','%s',NOW())" % (status, Interface)
	print condition_fan
	try:
		cursor.execute(condition_fan)
		db.commit()
		
	except MySQLdb.Error, e:
		print e.args[0],e.args[1]
		db.rollback() 
	return request.forms.get('status')
github ampedandwired / bottle-swagger / example / app.py View on Github external
def hello():
    thing_id = bottle.request.forms['thing_id']
    return {"id": thing_id, "name": "Thing{}".format(thing_id)}
github apache / incubator-retired-cotton / mysos / scheduler / http.py View on Github external
def create(self, clustername):
    """Create a db cluster."""
    cluster_name = clustername  # For naming consistency.
    num_nodes = bottle.request.forms.get('num_nodes', default=1)
    cluster_user = bottle.request.forms.get('cluster_user', default=None)
    backup_id = bottle.request.forms.get('backup_id', default=None)
    size = bottle.request.forms.get('size', default=None)
    cluster_password = bottle.request.forms.get('cluster_password', default=None)

    try:
      cluster_zk_url, cluster_password = self._scheduler.create_cluster(
          cluster_name,
          cluster_user,
          num_nodes,
          size,
          backup_id=backup_id,
          cluster_password=cluster_password)
      return json.dumps(dict(cluster_url=cluster_zk_url, cluster_password=cluster_password))
    except MysosScheduler.ClusterExists as e:
      raise bottle.HTTPResponse(e.message, status=409)
github mak / ipad / srv / cmd.py View on Github external
def get_user():
    user = request.forms.get('user')
    key =  request.forms.get('key')
    user = db.get_user(user,key)
    return user
github stump / keyrand / keyrandwebapp.py View on Github external
def post():
    seed = bottle.request.forms.get('seed')
    if seed == '':
        seed = '0'
    try:
        seed = int(seed)
    except ValueError:
        return get(error='<p class="error">Invalid seed.</p>')
    if seed &lt; 0 or seed &gt;= 4294967296:
        return get(error='<p class="error">Seed out of range.</p>')
    if seed == 0:
        seed = random.randrange(4294967296)
    rom = bottle.request.files.get('rom')
    if not rom:
        return get(error='<p class="error">ROM is required.</p>')
    romimage = bytearray(rom.file.read(1048576))
    if len(romimage) != 1048576 or rom.file.read(1) != b'':
        return get(error='<p class="error">Incorrect ROM size.</p>')
github kvfrans / deepcolor / server.py View on Github external
@route('/upload_canvas', method='POST')
def do_uploadc():
    print "Got it"
    # lines = request.files.get('lines')
    # colors = request.files.get('colors')
    line_data = request.forms.get("lines")
    line_data = re.sub('^data:image/.+;base64,', '', line_data)
    line_s = base64.b64decode(line_data)
    line_img = np.fromstring(line_s, dtype=np.uint8)
    line_img = cv2.imdecode(line_img, -1)

    color_data = request.forms.get("colors")
    color_data = re.sub('^data:image/.+;base64,', '', color_data)
    color_s = base64.b64decode(color_data)
    color_img = np.fromstring(color_s, dtype=np.uint8)
    color_img = cv2.imdecode(color_img, -1)

    lines_img = np.array(cv2.resize(line_img, (512,512)))
    lines_img = np.array([lines_img]) / 255.0
    lines_img = lines_img[:,:,:,0]
    lines_img = np.expand_dims(lines_img, 3)
github I2PC / scipion / pyworkflow / web / client / interactiveProtocol.py View on Github external
def readParametersFromLocal():
    print "Reading Parameters From Local..."
    
    inputParameters={}
    inputParameters['action'] = request.forms.get("action") #InteractiveProtocolMenu || TransferFilesMenu || RunInteractiveProtocol || RunTransferFiles 
    
    inputParameters['machine'] = request.forms.get("machine")
    inputParameters['user'] = request.forms.get("user")
    inputParameters['commands'] = request.forms.getall("commands")
    inputParameters['password'] = request.forms.get('password')
    
    inputParameters['numberTrials'] = request.forms.get("numberTrials",3)
    inputParameters['pathAskpass'] = request.forms.get("pathAskpass","scipionPipe")

    print "Parameters: ", inputParameters
    return inputParameters
github pyload / pyload-webui / pyload_webui / webui / cnl.py View on Github external
@route("/flash/addcrypted2", method="POST")
@local_check
def addcrypted2():

    package = request.forms.get("source", None)
    crypted = request.forms['crypted']
    jk = request.forms['jk']

    token = standard_b64decode(unquote(crypted.replace(" ", "+")))
    try:
        jk = "{0} f()".format(jk)
        jk = js2py.eval_js(jk)
    except AttributeError:
        try:
            jk = re.findall(r"return ('|\")(.+)('|\")", jk)[0][1]
        except Exception:
            # Test for some known js functions to decode
            if jk.find("dec") > -1 and jk.find("org") > -1:
                org = re.findall(r"var org = ('|\")([^\"']+)", jk)[0][1]
                jk = reversed(org)
                jk = "".join(jk)
github ieee-uiuc / drops / auth.py View on Github external
@post('/login')
def login():
	l = ldap.initialize("ldap://ad.uillinois.edu")
	l.set_option(ldap.OPT_REFERRALS, 0)
	l.set_option(ldap.OPT_PROTOCOL_VERSION, 3)
	l.set_option(ldap.OPT_X_TLS,ldap.OPT_X_TLS_DEMAND)
	l.set_option( ldap.OPT_X_TLS_DEMAND, True )
	l.set_option( ldap.OPT_DEBUG_LEVEL, 255 )
	l.start_tls_s()

	username = 'CN=' + request.forms.get('netid') + ',OU=People,DC=ad,DC=uillinois,DC=edu'
	password = request.forms.get('password')

	try: 
		l.simple_bind_s(username, password)
	except ldap.INVALID_CREDENTIALS:
		# -1 means the username or password was incorrect
		l.unbind_s();
		return "-1"
	except ldap.LDAPError, e:
		# -2 means there was some other error
		print(e)
		l.unbind_s();
		return "-2"
	# 0 means login successful
	l.unbind_s();
	return "0"