Exemple #1
0
#coding: utf-8
from web import form
from models import User
from operator import itemgetter

CreditForm = form.Form(
    form.Textbox('amount',
                 form.notnull,
                 form.regexp(r'[+-]?([0-9]*[.])?[0-9]+',
                             "Le montant entré n'est pas un chiffre valide"),
                 size=5,
                 post=" €",
                 description="Montant :"),
    form.Button('Envoyer'),
)

ConsumeForm = form.Form(
    form.Dropdown('units', [(x, x) for x in range(1, 11)],
                  description="Nombre de consommations"),
    form.Button('Envoyer'),
)

ConsumeInlineForm = form.Form(form.Textbox('units', size=5), )

UserForm = form.Form(
    form.Textbox('firstname', form.notnull, size=30, description="Prénom :"),
    form.Textbox('lastname', form.notnull, size=30, description="Nom :"),
    form.Textbox('email',
                 form.notnull,
                 form.regexp(
                     r'(^[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+$)',
Exemple #2
0
 def getForm(self):
     return form.Form(
         form.Textbox(
             "home",
             form.notnull,
             description="Home location",
             value=settings.get('location_home'),
         ),
         form.Textbox(
             "work",
             form.notnull,
             description="Work location",
             value=settings.get('location_work'),
         ),
         form.Textbox(
             "weatherloc",
             form.notnull,
             description="Weather location",
             value=settings.get('weather_location'),
         ),
         form.Textbox(
             "snooze",
             form.notnull,
             form.regexp('\d+', 'Must be a digit'),
             description="Snooze Length (minutes)",
             value=settings.getInt('snooze_length'),
         ),
         form.Textbox(
             "wakeup",
             form.notnull,
             form.regexp('\d+', 'Must be a digit'),
             description="Time (mins) before event for alarm",
             value=settings.getInt('wakeup_time'),
         ),
         form.Textbox(
             "precancel",
             form.notnull,
             form.regexp('\d+', 'Must be a digit'),
             description="Pre-empt cancel alarm allowed (secs)",
             value=settings.get('preempt_cancel'),
         ),
         form.Textbox(
             "waketime",
             form.notnull,
             form.regexp('[0-2][0-9][0-5][0-9]', 'Must be a 24hr time'),
             description="Default wakeup time",
             value=settings.get('default_wake'),
         ),
         form.Checkbox(
             "holidaymode",
             description="Holiday mode enabled",
             checked=(settings.getInt('holiday_mode') == 1),
             value="holiday",
         ),
         form.Checkbox(
             "weatheronalarm",
             description="Play weather after alarm",
             checked=(settings.getInt('weather_on_alarm') == 1),
             value="weatheronalarm",
         ),
         form.Checkbox(
             "sfx",
             description="SFX enabled",
             checked=(settings.getInt('sfx_enabled') == 1),
             value="sfx",
         ),
         form.Textbox(
             "ttspath",
             description="TTS path",
             value=settings.get('tts_path'),
         ),
     )
Exemple #3
0
import web
from web import form

render = web.template.render('templates/')

urls = ('/','index')
app = web.application(urls, globals())

myform = form.Form(
    form.Checkbox('csv'),
    form.Checkbox('jdf'),
    form.Dropdown('files',['csv','jdf']))

class index:
    def GET(self):
        form = myform()
        return render.formest(form)

    def POST(self):
       form = myform()
       if not form.validates():
           return render.formtest(form)
       else:
           return "Grrreat success! files:%s csv:%s jdf:%s" % (form['files'].value,form['csv'].get_value(),form['jdf'].checked)
            #return "type:form %s,%s" % ( form.get('csv').get_value(),form.get('csv').get_default_id())
if __name__ == "__main__":
    web.internalerror = web.debugerror
    app.run()
Exemple #4
0
    '/sf',
    'search_food',
    '/ss',
    'search_scene',
    '/sr',
    'route',
    '/si',
    'search_image',
    '/sii',
    'search_image_by_image',
)

render = web.template.render('templates')  # your templates

login = form.Form(
    form.Textbox('keyword'),
    form.Button('Search'),
)


def search_where(province, kind, query):
    province = 'shanghai'
    result_dict = Search(province, kind, query)
    if not type(result_dict) == type(''):
        if 'introduction' in result_dict.keys():
            result_dict['introduction'] = result_dict['introduction'].split(
                '\n')
        if 'img_list' in result_dict.keys():
            result_dict['img_list'] = result_dict['img_list'].split('\n')
        return result_dict
    else:
        return None
Exemple #5
0
__all__ = [
        'commentForm', 'linkForm', 'entryForm', 'pageForm',
    ]

username_validate = form.regexp(r".{3,15}$", u"请输入3-15位的用户名")
email_validate = form.regexp(r".*@.*", u"请输入合法的Email地址")
urlValidator = form.regexp(r"http://.*", u"请输入合法的URL地址")
captchaValidator = form.Validator('Captcha Code',
        lambda x: x == web.ctx.session.captcha)

commentForm = form.Form(
        form.Textbox('username', form.notnull, username_validate),
        form.Textbox('email', form.notnull, email_validate),
        form.Textbox('url'),
        form.Textbox('captcha', captchaValidator,
            description="Captcha Code"),
        form.Textarea('comment', form.notnull),
        form.Textbox('captcha', captchaValidator),
        form.Button('submit', type="submit", description=u"留言"),
    )

linkForm = form.Form(
        form.Textbox('name', form.notnull),
        form.Textbox('url', form.notnull, urlValidator),
        form.Textbox('description', form.notnull)
    )

entryForm = form.Form(
        form.Textbox('title', form.notnull),
        form.Textbox('content', form.notnull),
        form.Textbox('slug', form.notnull),
Exemple #6
0
import web
import os 
from web import form 

urls = (
	'/upload', 'Upload',
	'/unzip','Unzip',
  '/predict','Predict',
  '/download','Download',
  '/diagrame','Diagrame',
  '/.*','Upload')  

render = web.template.render('templates/')  

myform = form.Form(
    form.Checkbox("Export CSV",value='bar'),
    #form.Checkbox("Export JDF")
  )

class Upload:  
	def GET(self):  
		web.header("Content-Type","text/html; charset=utf-8")  
		return render.main_page()

	def POST(self):  
		x = web.input(myfile={})
		web.form.Button("save").render()
		web.form.Button("action", value="save", html="<b>Save Changes</b>").render()   
		filedir = '/home/hao/server/webpy' # change this to the directory you want to store the file in.  
		if 'myfile' in x: # to check if the file-object is created  
			filepath=x.myfile.filename.replace('\\','/') # replaces the windows-style slashes with linux ones.  
			filename=filepath.split('/')[-1] # splits the and chooses the last part (the filename with extension)  
Exemple #7
0
import web
import os
from videoGenerationAPI import generateSentenceVideo
from web import form

urls = ('/', 'index')
app = web.application(urls, globals())

myform = form.Form(
    form.Textarea('Text',
                  form.notnull,
                  rows=50,
                  cols=70,
                  description="Text Content"))


#render = web.template.render('templates')
class index:
    #def GET(self):
    #   form = myform()
    # make sure you create a copy of the form by calling it (line above)
    # Otherwise changes will appear globally

    #return render.formtest(form)

    def POST(self):
        form = myform()
        if not form.validates():
            render = web.template.render('templates')
            return render.formtest(form)
        else:
Exemple #8
0
RUNTIME_JAVA9 = "Java 9"
RUNTIME_JAVAOPENJDK9 = "Java OpenJDK 9"
RUNTIME_R = "R"
RUNTIME_HASKELL = "Haskell"
RUNTIME_PERL = "Perl"
RUNTIME_LUA = "Lua"
RUNTIME_SWIFT = "Swift"
RUNTIME_OBJECTIVEC = "Objective-c"
RUNTIME_ELIXIR = "Elixir"
RUNTIME_RUST = "Rust"

myform = form.Form(
    form.Dropdown("Runtime", [
        RUNTIME_PYTHON27, RUNTIME_PYTHON35, RUNTIME_GOLANG, RUNTIME_UBUNTU,
        RUNTIME_CENTOS, RUNTIME_C, RUNTIME_CPP, RUNTIME_RUBY, RUNTIME_ERLANG,
        RUNTIME_NODE, RUNTIME_PHP, RUNTIME_JAVA9, RUNTIME_JAVAOPENJDK9,
        RUNTIME_R, RUNTIME_HASKELL, RUNTIME_PERL, RUNTIME_LUA, RUNTIME_SWIFT,
        RUNTIME_OBJECTIVEC, RUNTIME_ELIXIR, RUNTIME_RUST
    ]), form.Textbox("Load local file"), form.Checkbox("Edit online code"),
    form.Textarea("Online code"))

urls = ('/', 'index')


class index:
    '''
    Return web form to trigger lambda service.
    '''
    def GET(self):
        form = myform()
Exemple #9
0
#! /usr/bin/env python2
# -*- coding: utf-8 -*-

import web
from web import form
from search import *

render = web.template.render('templates/')

urls = ('/', 'index')
app = web.application(urls, globals())

myform = form.Form(
    form.Textbox('Title: '),
    form.Dropdown('Type: ', ['','TOPIC', 'PERSON',]),
    form.Dropdown('Action: ', ['Index', 'Search']),
    form.Button('Execute'),)

class index:

    def GET(self):
        form = myform()
        return render.index(form)

    def POST(self):
	form = myform()

        search = Search(form['Title: '].value, form['Type: '].value)

	if not form.validates():
            return render.index(form)
Exemple #10
0
db = web.database(dbn = 'mysql', port = 3306, host = '127.0.0.1', \
    user = '******', pw = password, db = 'upload_table')

pubhome = os.environ.get('public_home')
render = web.template.render(pubhome + '/base_code/webpy/templates/')

urls = ('/', 'index')

myform = form.Form(
    form.Textbox('项目名称*', form.notnull),
    form.Textbox('项目ID',
                 form.regexp('\d+', '必须为数字'),
                 form.Validator('必须为正整数', lambda x: int(x) > 0),
                 value=0),
    form.Textbox('销售额*', form.notnull, form.regexp('\d+', '必须为数字'),
                 form.Validator('必须为正数', lambda x: float(x) > 0)),
    form.Textbox('出票量',
                 form.regexp('\d+', '必须为数字'),
                 form.Validator('必须为正整数', lambda x: int(x) > 0),
                 value=1), form.Textbox('打款日期*', form.notnull),
    form.Textbox('负责BD*', form.notnull), form.Dropdown('打款方式*',
                                                       ['公对公', '私对公']),
    form.Textbox('分销方'), form.Textbox('佣金比例', value=0))


class index:
    def GET(self):
        form = myform()
        # make sure you create a copy of the form by calling it (line above)
        # Otherwise changes will appear globally
        #return render.index(todos,form)
import web
from web import form

from app.models import users
from app.helpers import session
from app.helpers import email_templates

import config
from config import view

vemail = form.regexp(r'.+@.+', 'Please enter a valid email address')
login_form = form.Form(
    form.Textbox('email', form.notnull, vemail, description='Your email:'),
    form.Password('password', form.notnull, description='Your password:'******'submit', type='submit', value='Login'),
    validators=[
        form.Validator(
            'Incorrect email / password combination.',
            lambda i: users.is_correct_password(i.email, i.password))
    ])

register_form = form.Form(
    form.Textbox('email',
                 form.notnull,
                 vemail,
                 form.Validator('This email address is already taken.',
                                lambda x: users.is_email_available(x)),
                 description='Your email:'),
    form.Password('password',
                  form.notnull,
                  form.Validator(
Exemple #12
0
    urls = ('/', 'index')
    app = web.application(urls, globals())

    db = web.database(dbn='sqlite', db='recipes.db')

    def execute_SQL(sql_statement):
        #c.execute(sql_statement)
        #return c.fetchall()
        #for each in list(result):
        #    print each['id']
        return list(db.query(sql_statement))

    myform = form.Form(
        form.Textbox("ingredient", value=""),
        form.Textarea("list", description="List of ingredients", value=""),
        form.Dropdown('reset', ['no', 'yes'],
                      description="Reset ingredients?"),
        #form.Dropdown('sort', ['A-Z','rating','calories','cost','number of ingredients'], description="Sort by"),
        #form.Checkbox('Reset', checked=False),
        form.Button("Update"))

    ingredients_AND_list = []
    ingredients_list = []  # keep track of requested ingredients

    class index:
        def GET(self):
            f = myform()
            #recipes = execute_SQL("SELECT name, url FROM recipes where ing_1=1")
            # make sure you create a copy of the form by calling it (line above)
            # Otherwise changes will appear globally
            return render.main(f, [])
Exemple #13
0
myform = form.Form(
    form.Textbox('departureCity', form.notnull, description="Departure city", class_="textEntry",\
  value="Madrid", id="cajatext", post="  City where you want to start your travel. It should has an airport.", size="15"),

    form.Textbox('firstPossibleDepartureDate', form.notnull, description="First possible departure date", class_="textEntry",\
  value="YYYY-MM-DD", id="cajatext", post="  First  day on which you can start your trip.", size="15"),

    form.Textbox('lasttPossibleDepartureDate', form.notnull, description="Last possible departure date", class_="textEntry",\
  value="YYYY-MM-DD", id="cajatext", post="  Last day on which you can start your trip: The more flexible you are, the better suggestions we can give you!!", size="15"),

    form.Textbox('duration', form.notnull, description="Trip duration", class_="textEntry",\
  value="7", id="cajatext", post="  How many days will your trip last?", size="15"),

    form.Textbox('currency', form.notnull, description="Your local currency", class_="textEntry",\
  value="EUR", id="cajatext", post="  EUR/GBP/USD/CNY...Which is the currency in the departure airport?", size="15"),

    #  form.Textbox("nombre"),
    #  form.Textbox("id1",
    #    form.notnull,
    #    form.regexp('\d+', 'Debe ser un dígito'),
    #    form.Validator('Debe ser más de 5', lambda x:int(x)>5)),
    #  form.Textbox("id2",
    #    form.notnull,
    #    form.regexp('\d+', 'Debe ser un dígito'),
    #    form.Validator('Debe ser más de 5', lambda x:int(x)>5)),
    #  form.Textarea('observacion'),
    #  form.Checkbox('reenviar'),
    form.Dropdown('yourProfile', ['Equilibrated tourist','Tan-aholic','Student','Only one live','Keep me warm',"Ecotourist"],description="Your tourist profile",\
  post="how would you describe your self?", size="6"),

    form.Textbox('budget', form.notnull, description="What is your budget?", class_="textEntry",\
  value="500", id="cajatext", post=" How much money you want to spent? (EUR/GBP/USD...)", size="15"),
)
Exemple #14
0
            return True
        if redirect:
            raise web.unauthorized()
        return False

    if redirect:
        raise web.seeother(u"/login")
    return False


signin_form = form.Form(
    form.Password(
        name=u'password', description=_(u"Passphrase") + u":", value=u''
        ),

    validators=[
        form.Validator(
            _(u"Incorrect passphrase, please try again"),
            lambda x: gv.sd[u"passphrase"] == password_hash(x.password),
        )
    ],
)


def get_input(qdict, key, default=None, cast=None):
    """
    Checks data returned from a UI web page.
    """
    result = default
    if key in qdict:
        result = qdict[key]
        if cast is not None:
Exemple #15
0
    if 'pw' in qdict:
        if gv.sd['password'] == password_hash(qdict['pw'], gv.sd['salt']):
            return True
        if redirect:
            raise web.unauthorized()
        return False

    if redirect:
        raise web.seeother('/login')
    return False


signin_form = form.Form(form.Password('password',
                                      description=_('Password') + ':'),
                        validators=[
                            form.Validator(
                                _("Incorrect password, please try again"),
                                lambda x: gv.sd['password'] == password_hash(
                                    x.password, gv.sd['salt']))
                        ])


def get_input(qdict, key, default=None, cast=None):
    """
    Checks data returned from a UI web page.
    
    
    """
    result = default
    if key in qdict:
        result = qdict[key]
        if cast is not None:
Exemple #16
0
class Logout(object):
    def GET(self):
        session.loggedin = False
        session.kill()
        raise web.seeother('/')


# email validator
vemail = form.regexp(r".*@.*", "must be a valid email address")

# New user form
new_user_form = form.Form(form.Textbox('username', description="Username"),
                          form.Textbox('email', vemail, description="E-Mail"),
                          form.Password('password', description="Password"),
                          form.Password('password_again',
                                        description="Confirm Password"),
                          validators=[
                              form.Validator(
                                  "Passwords didn't match.",
                                  lambda i: i.password == i.password_again)
                          ])


# Create a new user page
class NewUser(object):
    def GET(self):
        cur_form = new_user_form()
        return homepage_render.newuser("New User", cur_form, session.loggedin)

    def POST(self):
        cur_form = new_user_form()
        if cur_form.validates():
Exemple #17
0
authentication_va = form.Validator(
    authentication_msg,
    lambda i: auth.User.get_user(i.username).authenticate(i.password))

username_field = form.Textbox('username', username_va)
password_field = form.Password('password', password_va)
new_pw_field = form.Password('new', password_va, descrption='new password')
pw_confirmation_field = form.Password('confirm',
                                      password_va,
                                      description='confirm password')
email_field = form.Textbox('email', email_va, description='e-mail')

login_form = form.Form(username_field,
                       password_field,
                       validators=[
                           authentication_va,
                       ])

register_form = form.Form(username_field,
                          email_field,
                          password_field,
                          pw_confirmation_field,
                          validators=[
                              confirmation_va,
                              account_reg_va,
                          ])

pw_reset_form = form.Form(password_field,
                          new_pw_field,
                          pw_confirmation_field,
Exemple #18
0
        return (books, None)
    else:
        return (books, next['href'])


urls = (
    '/',
    'index',
    '/error',
    'error',
)
render = web.template.render('templates/')

searchfor_form = form.Form(form.Textbox("findthis", description="Search for"),
                           form.Button("submit",
                                       type="submit",
                                       description="Search"),
                           validators=[form.Validator("blah", lambda x: True)])


class index:
    def GET(self):
        f = searchfor_form()
        return render.index(f)

    def POST(self):
        f = searchfor_form()
        f.validates()
        (books, pages) = search_for(f.d.findthis)
        return render.results(books, f.d.findthis, pages)
Exemple #19
0
        user_info = model.get_userbyemail(email)
        password = user_info['password']
        #return password
        #send_mail(email, "password", "%s" %password, cc=None, bcc=None)


vpass = form.regexp(r".{3,20}$", 'must be between 3 and 20 characters')
vemail = form.regexp(r".*@.*", "must be a valid email address")

register_form = form.Form(form.Textbox("username", description="Username"),
                          form.Textbox("email", vemail, description="E-Mail"),
                          form.Password("password",
                                        vpass,
                                        description="Password"),
                          form.Password("password2",
                                        description="Repeat password"),
                          form.Button("reg", type="submit", description="reg"),
                          validators=[
                              form.Validator(
                                  "Passwords did't match",
                                  lambda i: i.password == i.password2)
                          ])

login_form = form.Form(
    form.Textbox("username", description="Username"),
    form.Password("password", vpass, description="Password"),
    form.Button("login", type="submit", description="login"))

forget_form = form.Form(
    form.Textbox("email", description="email"),
    form.Button("getpass", type="submit", description="getpass"))
Exemple #20
0
    'view_cluster_dot',
)

app = web.application(urls, globals())
render = web.template.render('templates/')
if web.config.get('_cn_session') is None:
    session = web.session.Session(app, web.session.DiskStore('cn-sessions'),
                                  {'user': None})
    web.config._cn_session = session
else:
    session = web.config._cn_session

register_form = form.Form(
    form.Textbox("username", description="Username"),
    form.Password("password", description="Password"),
    form.Button("submit", type="submit", description="Login"),
    validators=[
        form.Validator("All fields are mandatory",
                       lambda i: i.username == "" or i.password == "")
    ])

#-----------------------------------------------------------------------
# FUNCTIONS


#-----------------------------------------------------------------------
def create_schema_mysql(db):
    printing = db.printing
    db.printing = False
    db.dbn = get_dbn()

    sql = """create table if not exists config (
from web import form
from dataRegClientes import clientes
from dataRegPeliculas import peliculas

render = web.template.render('views', base='base')

urls=(
    '/(.*)','index')
db = web.database(dbn='mysql',db='peliculas',user='******',pw='utec')
clientes = clientes()
clientes.readRegClientes()
peliculas = peliculas()
peliculas.readRegPeliculas()
myformClientes= form.Form(
    form.Dropdown('Cliente', clientes.getCliente()),
    form.Dropdown('Pelicula', peliculas.getPelicula()),
    form.Dropdown('Formato',["Blueray","DVD"]),
    form.Dropdown('Tiempo',["1","2","3","4","5","6","7","8","9"])
)

class index:
    def GET(self,results):
        form = myformClientes()
        result = db.select('peliculasss')
        return render.index(form, result)

    def POST(self, results):
        form = myformClientes()
        if not form.validates():
            return render.index(form)
        else:
            costo=0
Exemple #22
0
from script.globalconfig import gconfig, lockertime

from script.flickrquery import Download, FlickrQuery
from script.eventmedia import eventinfo

from script.filter import filter
from script.refine import refine
from script.getfeature import getfeature
from script.toolkit import *

render = web.template.render('templates/')

urls = ('/', 'index')
app = web.application(urls, globals())

myform = form.Form(
    form.Textbox("bax", id="search", type="text", placeholder="Type here"), )


class index:
    def GET(self):
        html = open('index.html').readlines()
        return ' '.join(html)

    def POST(self):
        form = myform()
        if not form.validates():
            return render.formtest(form)
        else:
            tmp = web.input()
            op = tmp['query']
            string = tmp['textfield']
Exemple #23
0
import web
from web import form

urls = ('/', 'index', '/view', 'view', '/upload', 'upload')

render = web.template.render('templates/', base='layout')

upload_form = form.Form(form.File("myfile"))


class index:
    def GET(self):
        return render.index()


class view:
    def GET(self):
        return render.view()


class upload:
    def GET(self):
        form = upload_form()
        return render.upload(form)

    def POST(self):
        x = web.input(myfile={})
        filedir = 'tmp'
        if 'myfile' in x:
            fname = x.myfile.filename.split('/')[-1]
            fout = open(filedir + '/' + fname, 'wb')
Exemple #24
0
    '/formulario/',
    'formulario'  #nombre de la clase que crearemos despues
)


def notfound():
    return web.notfound("Lo sentimos no furula la pagina.")


app = web.application(urls, globals())
app.notfound = notfound

myform = form.Form(
    form.Textbox("Nombre"),
    form.Textbox(
        "Numero", form.notnull, form.regexp('\d+', 'Deben de ser digitos.'),
        form.Validator('Debe de ser 9 o mas digitos', lambda x: int(x) >= 9)),
    form.Textarea('Comentario'), form.Checkbox('Acepto los terminos.'),
    form.Dropdown('Espanol', ['Basico', 'Normal', 'Experto']))


class formulario:
    def GET(self):
        form = myform()
        return render.formtest(form)

    def POST(self):
        form = myform()
        if not form.validates():
            return render.formtest(form)
        else:
        plt.savefig(filename)
        return


render = web.template.render('templates/')
urls = ('/', 'index')
app = web.application(urls, globals())

myform = form.Form( 
    form.Textbox("First time frame (in seconds >  0hr)",form.notnull), 
    form.Textbox("Final time frame (in seconds <  4hr)",form.notnull), 
    form.Textbox("S/N minimum (> 5)",
        form.notnull,
        form.regexp('\d+', 'Must be a digit'),
        form.Validator('Must be => 5', lambda x:np.round(float(x))>4)
                ),
    form.Textbox("DM minimum trials (in pc cm^-3 and >    0)",form.notnull),
    form.Textbox("DM maximum trials (in pc cm^-3 and < 5000)",form.notnull),
    form.Textbox("Temporal min. decimation (in second and > 0.0)",form.notnull),
    form.Textbox("Temporal max. decimation (in second and < 10.0)",form.notnull)#,
    #form.Textbox("mjd",form.notnull)

                  )

class index: 
    def GET(self): 
        form = myform()
        # make sure you create a copy of the form by calling it (line above)
        # Otherwise changes will appear globally
        return render.formtest(form)
render = web.template.render('templates/')

urls = ('/', 'index', '/results', 'results', "/totalstuff", 'totalstuff',
        "/daterange", "daterange", "/fieldsearch", 'fieldsearch', "/mwsearch",
        "mwsearch", "/phrasesearch", "phrasesearch")

app = web.application(urls, globals())

movieix = b.build_es_movies_index()

fields = [
    "title", "language", "country", "director", "location", "starring", "text",
    "categories", "time", "runtime"
]

totalsize = form.Form(form.Button("Total size of index"))
date_range = form.Form(form.Textbox("Lower bound of date range:"),
                       form.Textbox("Upper bound of date range:"))
field_search = form.Form(form.Dropdown(name="Fields", args=fields),
                         form.Textbox("Text to search in field:"))
multiword = form.Form(form.Textbox("Multiword search:"))
phrase = form.Form(form.Textbox("Phrase search:"))
field_combo = form.Form(form.Textbox("Multifield search:"))


class index:
    def GET(self):
        form1 = totalsize()
        form2 = date_range()
        form3 = field_search()
        form4 = multiword()
Exemple #27
0
urls = ('/(.*)', 'index')

db = web.database(
    dbn='mysql',
    db='ei61l2qid60lviw9',
    user='******',
    pw='qpk282xn6jyssh05',
    host='o61qijqeuqnj9chh.cbetxkdyhwsb.us-east-1.rds.amazonaws.com')

Clientes = Clientes()
Clientes.read()
Pelis = Peliculas()
Pelis.read()

myform = form.Form(form.Dropdown('NombreCliente', Clientes.getClientes()),
                   form.Dropdown('Pelicula', Pelis.getPeliculas()),
                   form.Dropdown('Formato', ["BluRay", "DVD", "VHS"]),
                   form.Dropdown('Duracion', ["1", "2", "3", "4"]))


class index:
    def GET(self, results):
        form = myform()
        resultado = db.select('renta')
        return render.index(form, resultado)

    def POST(self, results):
        form = myform()
        if not form.validates():
            return render.index(form)
        else:
            precio = 0
Exemple #28
0
import web
from web import form
import subprocess
from functions import set_control, get_temp, update_figure

render = web.template.render('templates/')
urls = ('/', 'index', '/settings', 'settings')
app = web.application(urls, globals())

myform = form.Form(
    form.Checkbox('Turn on Control'),
    form.Textbox('Desired BBQ Temp', form.notnull,
                 form.regexp('\d+', 'Error: Temperature must be a digit')),
    form.Checkbox('Turn on Alert'),
    form.Textbox("Highest Allowable Temp of BBQ", form.notnull,
                 form.regexp('\d+', 'Error: Temperature must be a digit')),
    #form.Validator('Must be between 150 and 500 F', lambda x:150<int(x)<500)),
    form.Textbox("Desired Meat Temp", form.notnull,
                 form.regexp('\d+', 'Error: Temperature must be a digit')),
    #form.Validator('Must be between 150 and 500 F', lambda x:150<int(x)<500)),
    form.Button("Submit"))


class index:
    def GET(self):
        tempout = get_temp()
        update_figure()
        return render.main_page(tempout)


class settings:
Exemple #29
0
    'Updatelog',
    '/source_code',
    'Sourcecode',
    '/logoff',
    'Logoff',
    '/stopserver',
    'Stopserver',
    '/result_sensor_ultrasonic',
    'Result_sensor_ultrasonic',
)

app = web.application(urls, globals())

loginform = form.Form(
    form.Textbox("USERNAME", form.notnull,
                 form.Validator('wrong', lambda x: x == "martin")),
    form.Textbox("PASSWORD", form.notnull,
                 form.Validator('wrong', lambda x: x == "12341234")),
    form.Checkbox('I am not a robot'))

render = web.template.render('templates/')


class Login:
    def GET(self):
        return render.login(loginform)

    def POST(self):
        if not loginform.validates():
            return render.login(loginform)
        else:
            sensor.gpio_startup()
Exemple #30
0
def _set_value(self, value):
    self.value = value.strip()


form.Input.set_value = _set_value

SignUpForm = form.Form(
    form.Textbox('name'),
    form.Textbox('rating'),
    form.Textbox('passwd'),
    validators=[
        form.Validator(
            'Password length too short.',
            lambda i: len(i.passwd) >= 4,
        ),
        form.Validator(
            'Names are only letters and spaces.',
            lambda i: re.match(r"^[-'_ a-zA-Z0-9]+$", i.name),
        ),
        form.Validator(
            'Invalid rating. (30k - 7d)', lambda i:
            (i.rating[-1] in 'dD' and 1 <= int(i.rating[:-1]) <= 7 or i.rating[
                -1] in 'kK' and 1 <= int(i.rating[:-1]) <= 30)),
    ],
)

LoginForm = form.Form(
    form.Textbox('name'),
    form.Textbox('passwd'),
    validators=[
        form.Validator(