Ejemplo n.º 1
1
def index():
    form = InputForm(request.form)
    if request.method == 'POST' and form.validate():
        arg_names = inspect.getargspec(compute).args
        kwargs = {name: getattr(form, name).data
                  for name in arg_names if hasattr(form, name)}
        # Run eval on the text
        # Note that form.name.label is <label for="A">(list)</label>
        for name in kwargs:
            if hasattr(form, name) and \
                   hasattr(getattr(form, name), 'label'):
                label = str(getattr(form, name).label)
                for tp in ('(list)', '(tuple)', '(nd.array)'):
                    if tp in label:
                        kwargs[name] = eval(kwargs[name])

        result = compute(**kwargs)
    else:
        result = None

    # Concatenate view_forms.html and view_results.html
    result_render = None
    if result:
	    result_render = render_template('view_results.html', result=result)
    return render_template('view_forms.html',
                           form=form, result=result_render)
Ejemplo n.º 2
0
def upload_file():
    form = InputForm(request.form)
    if request.method == 'POST' and form.validate():
        result = compute(form.A.data, form.b.data, form.w.data, form.T.data)
    else:
        result = None
    return render_template('view_plain.html', form=form, result=result)
Ejemplo n.º 3
0
def usingdata():
    form = InputForm(request.form)
    if request.method == 'POST' and form.validate():
        result = compute(form.a.data, form.b.data,form.c.data, form.d.data,form.e.data,form.z.data,form.g.data,form.h.data,form.i.data)
    else:
        result = None
    return render_template('usingdata.html', form=form, result=result)
Ejemplo n.º 4
0
def index():
    form = InputForm(request.form)
    if request.method == 'POST' and form.validate():
        a = form.formula.data  # String
        b = form.N.data  # Float
        c = form.independent_variable.data  # String
        d = form.xMin.data  # Float
        e = form.xMax.data  # Float
        f = form.yMin.data  # Float
        g = form.yMax.data  # Float
        h = form.degree_of_approximation.data  # Float
        i = form.eCurves.data  # Select
        j = form.legend_loc.data  # Select

        result = compute(a, c, b, d, e, f, g, i, j)

        result_2 = latexSeries(a, c, b, h)

    else:
        result = None
        result_2 = None

    return render_template("view_plain.html",
                           form=form,
                           result=result,
                           result_2=result_2)
Ejemplo n.º 5
0
def index():
    form = InputForm(request.form)
    if request.method == 'POST' and form.validate():
        arg_names = inspect.getargspec(compute).args
        kwargs = {
            name: getattr(form, name).data
            for name in arg_names if hasattr(form, name)
        }
        result = compute(**kwargs)
    else:
        result = None
    # Concatenate view_forms.html and view_results.html
    forms_html = os.path.join('templates', 'view_forms.html')
    results_html = os.path.join('templates', 'view_results.html')
    view_html = os.path.join('templates', 'view.html')
    f_forms = open(forms_html, 'r')
    f_res = open(results_html, 'r')
    f_view = open(view_html, 'w')
    f_view.write(f_forms.read() + f_res.read())
    f_forms.close()
    f_res.close()
    f_view.close()
    return render_template(os.path.basename(view_html),
                           form=form,
                           result=result)
Ejemplo n.º 6
0
def index():
    form = InputForm(request.form)
    if request.method == 'POST' and form.validate():

        result_coherence = calc_coherence(unpack_data(form.text_input))
        result_determiners = calc_determiners(unpack_data(form.text_input))
        result_phrase_length = calc_phrase_len(unpack_data(form.text_input))
        result_delusion_dict = calc_delusions(unpack_data(form.text_input))

        filtered_results = [
            1 - min(result_coherence), result_determiners,
            result_phrase_length, result_delusion_dict
        ]

        result_a1 = result_delusion_dict['time']
        result_a2 = result_delusion_dict['self']
        result_a3 = result_delusion_dict['surveillance']
        result_a4 = result_delusion_dict['unfair']
        result_a5 = result_delusion_dict['mind_control']
        result_a6 = result_delusion_dict['alien']

        result_ml = calc_ml(result_coherence, result_determiners,
                            result_phrase_length, result_a1, result_a2,
                            result_a3, result_a4, result_a5, result_a6)

        return render_template('results.html',
                               form=form,
                               result_ml=result_ml,
                               filtered_results=filtered_results)
    else:
        return render_template('view.html', form=form)
Ejemplo n.º 7
0
def index():
    global return_puzzle
    categories = get_categories()
    form = InputForm(request.form)
    if request.method == 'POST' and form.validate():
        clue = form.clue.data
        puzzle_type = form.puzzle_type.data
        print puzzle_type
        if puzzle_type not in categories.keys():
            mypuzzlesheet = puzzlesheet.puzzlesheet("puzzle",
                                                    "",
                                                    clue,
                                                    savetex=True)
            mypuzzlesheet.add_section(
                puzzle_type,
                6,
                "",
                puzzlesheet.instructions_map[puzzle_type],
                rhs=0)
            mypuzzlesheet.write()
            return_puzzle = "puzzle.pdf"
        else:
            mypuzzlesheet = crosswordsheet.crossword1d(categories[puzzle_type],
                                                       title=puzzle_type,
                                                       clue=clue,
                                                       savetex=True)
            mypuzzlesheet.add_section()
            mypuzzlesheet.write()
            return_puzzle = mypuzzlesheet.fname + ".pdf"
        return redirect('/return-files/')

    else:
        clue = None

    return render_template("view.html", form=form, clue='defaulto')
Ejemplo n.º 8
0
def index():
    form = InputForm(request.form)
    if request.method == "POST" and form.validate():
        result = compute(form.A.data, form.b.data, form.w.data, form.T.data)
    else:
        result = None
    return render_template("view.html", form=form, result=result)
Ejemplo n.º 9
0
def index():
    form = InputForm(request.form)
    if request.method == 'POST' and form.validate():
        arg_names = inspect.getargspec(compute).args
        kwargs = {
            name: getattr(form, name).data
            for name in arg_names if hasattr(form, name)
        }
        # Run eval on the text
        # Note that form.name.label is <label for="A">(list)</label>
        for name in kwargs:
            if hasattr(form, name) and \
                   hasattr(getattr(form, name), 'label'):
                label = str(getattr(form, name).label)
                for tp in ('(list)', '(tuple)', '(nd.array)'):
                    if tp in label:
                        kwargs[name] = eval(kwargs[name])

        result = compute(**kwargs)
    else:
        result = None
    if result:
        # result must be transformed to HTML and inserted as a
        # string in the generic view.html file
        result = render_template('view_results.html', result=result)
    return render_template('view.html', form=form, result=result)
Ejemplo n.º 10
0
def predict():

    form = InputForm(request.form)
    print(form)
    LOG.info("Form Require: {form}")

    if request.method == 'POST' and form.validate():
        # Convert Input Table Data to DataFrame
        clf = joblib.load('ny_airbnb_prediction.joblib')
        df_input = create_dataframe(form)
        LOG.info("Convert Input to DataFrame: {df_input}")
        # Predict Price
        prediction = clf.predict(df_input)
        LOG.info("Predict: {prediction}")
        # Convert to String Output
        final_output = "Predicted Price: $" + str(numpy.power(
            10, prediction))[1:-1]
        result = final_output
        print("output")
        print(final_output)

    else:
        result = None

    return render_template('predict.html', form=form, result=result)
Ejemplo n.º 11
0
def index():
    c, conn = connection()
    form = InputForm(request.form)
    if request.method == 'POST':
        if form.validate():
            result = generatequery(form.query_string.data)
            c.execute(str(result))
            result_table = c.fetchall()
            result_header = [x[0] for x in c.description]
        else:
            result = 'Invalidate Form'
            result_table = None
            result_header = None
    else:
        result = "SELECT variant_id,chrom,pos,strain_name,allele_1,allele_2 from genotype_view limit 10"
        result_table = [[1L, '1', 3206310L, 'CC040_TauUncb38V01', 'AT', 'AT'],
                        [1L, '1', 3206310L, 'CC001_Uncb38V01', 'AT', 'AT'],
                        [1L, '1', 3206310L, 'CC002_Uncb38V01', 'AT', 'AT'],
                        [1L, '1', 3206310L, 'CC003_Uncb38V01', 'AT', 'AT'],
                        [1L, '1', 3206310L, 'CC009_Uncb38V01', 'AT', 'AT'],
                        [1L, '1', 3206310L, 'CC012_GeniUncb38V01', 'AT', 'AT'],
                        [1L, '1', 3206310L, 'CC013_GeniUncb38V01', 'AT', 'AT'],
                        [1L, '1', 3206310L, 'CC026_GeniUncb38V01', 'AT', 'AT'],
                        [1L, '1', 3206310L, 'CC037_TauUncb38V01', 'AT', 'AT'],
                        [1L, '1', 3206310L, 'CC059_TauUncb38V01', 'AT', 'AT']]
        result_header = [
            'variant_id', 'chrom', 'pos', 'strain_name', 'allele_1', 'allele_2'
        ]
    return render_template("index2.html",
                           form=form,
                           result=result,
                           result_table=result_table,
                           result_header=result_header)
Ejemplo n.º 12
0
def index():
    form = InputForm(request.form)
    if request.method == 'POST' and form.validate():
        CBM = getCBM(form.l.data, form.w.data, form.h.data)
        price1 = getPrePrice(form.PLZ.data, CBM, form.Weight.data)
        price2 = getPostPrice(form.Province.data, form.City.data, CBM,
                              form.Weight.data)
        #result = compute(form.A.data, form.b.data,form.w.data, form.T.data)
        eu2us = form.eu2us.data
        us2rmb = form.us2rmb.data

        FOG = CBM * form.FOG.data
        ISPS = form.ISPS.data
        Un_loading = form.Weight.data * form.Un_loading.data
        CFS = CBM * form.CFS.data
        Anti_Terror = form.Terror.data
        Cargo_Service = form.Cargo.data
        #Pickup = 200 * eu2us
        Custom_clearance = form.Custom.data / us2rmb

        price3 = price1 * eu2us + price2 / us2rmb + (
            FOG + ISPS + Un_loading + CFS + Anti_Terror + Custom_clearance +
            Cargo_Service)

    else:
        price1 = None
        price2 = None
        price3 = None
        #result = None

    return render_template('view_plain.html',
                           form=form,
                           price1=price1,
                           price2=price2,
                           price3=price3)
Ejemplo n.º 13
0
def index():
    form = InputForm(request.form)
    if request.method == 'POST' and form.validate():
        arg_names = inspect.getargspec(compute).args
        kwargs = {
            name: getattr(form, name).data
            for name in arg_names if hasattr(form, name)
        }
        # Run eval on the text
        # Note that form.name.label is <label for="A">(list)</label>
        for name in kwargs:
            if hasattr(form, name) and \
                   hasattr(getattr(form, name), 'label'):
                label = str(getattr(form, name).label)
                for tp in ('(list)', '(tuple)', '(nd.array)'):
                    if tp in label:
                        kwargs[name] = eval(kwargs[name])

        result = compute(**kwargs)
    else:
        result = None

    # Concatenate view_forms.html and view_results.html
    result_render = None
    if result:
        result_render = render_template('view_results.html', result=result)
    return render_template('view_forms.html', form=form, result=result_render)
Ejemplo n.º 14
0
def method():
    form = InputForm(request.form)
    if request.method == 'POST' and form.validate():
        result = anomaly_det(form.M.data, form.S.data)
    else:
        result = None
    return render_template( 'options.html',
                           form=form, result=result)
Ejemplo n.º 15
0
def index():
    form = InputForm(request.form)
    if form.validate():
        result = compute(form.A.data, form.b.data, form.w.data, form.T.data)
    else:
        result = None

    return render_template('view.html', form=form, result=result)
Ejemplo n.º 16
0
def index():
    form = InputForm(request.form)
    if form.validate():
        result = compute(form.Fsr.data, form.freq.data)
    else:
        result = None

    return render_template('view.html',form=form, result=result)
Ejemplo n.º 17
0
def index():
    form = InputForm(request.form)
    if request.method == 'POST' and form.validate():
        result = compute(form.A.data, form.b.data, form.w.data, form.T.data)
    else:
        result = None

    return render_template(template_name + '.html', form=form, result=result)
Ejemplo n.º 18
0
def index():
    form = InputForm(request.form)
    if request.method == 'POST' and form.validate():
        result = phasePlot(form.XPrime.data, form.YPrime.data)
    else:
        result = None
        
    return render_template('new_view.html', form=form,result=result)
Ejemplo n.º 19
0
def init():
    form = InputForm(request.form)
    if request.method == 'POST' and form.validate():
        result = compute(form.Artist.data, form.Song.data)
    else:
        result = None

    return render_template('example.html', form=form, result=result)
Ejemplo n.º 20
0
def index():
    form = InputForm(request.form)
    if request.method == 'POST' and form.validate():
        result = compute(form.STOCK_NAME.data)
    else:
        result = compute('AAPL')

    return render_template('view.html', form=form, result=Markup(result))
Ejemplo n.º 21
0
def index():
    form = InputForm(request.form)
    if request.method == 'POST' and form.validate():
        r = form.r.data
        s = compute(r)
        return render_template("view_output.html", form=form, s=s)
    else:
        return render_template("view_input.html", form=form)
Ejemplo n.º 22
0
def index():
    form = InputForm(request.form)
    if request.method == 'POST' and form.validate():
        result = compute(form.Formula.data, form.Domain.data, form.Erase.data)
    else:
        result = None

    return render_template('view.html', form=form, result=result)
Ejemplo n.º 23
0
def index():
    form = InputForm(request.form)  #form represents an instance of the InputForm
    if form.validate():
        result = compute(form.A.data, form.B.data) #Result holds the output image
    else:
        result = None

    return render_template('view.html', form=form, result=result)
Ejemplo n.º 24
0
def index():
    form = InputForm(request.form)
    if request.method == 'POST' and form.validate():
        result = phasePlot(form.XPrime.data, form.YPrime.data)
    else:
        result = None

    return render_template('new_view.html', form=form, result=result)
Ejemplo n.º 25
0
def home():
    # mapped = mapper()
    form = InputForm(request.form)
    if request.method == 'POST' and form.validate():
        result = compute(form.A.data, form.b.data, form.w.data, form.T.data)
    else:
        result = None

    return render_template("home.html", form=form, result=result)
Ejemplo n.º 26
0
def index():
    form = InputForm(request.form)
    if request.method == 'POST' and form.validate():
        r = form.r.data
        s = compute(r)
    else:
        s = None

    return render_template("view.html", form=form, s=s)
Ejemplo n.º 27
0
def index():
    form = InputForm(request.form)
    if request.method == 'POST' and form.validate():
        result = compute_maps(form.date.data, form.integration_time.data,
                              form.start_time.data)
    else:
        result = None

    return render_template('view.html', form=form, result=result)
Ejemplo n.º 28
0
def index():
    form = InputForm(request.form)
    if request.method == 'POST' and form.validate():
        r = form.r.data
        s = compute(r)
        a = form.a.data
        b = form.b.data
        s_add = add(a,b)
		s =(s,s_add)
Ejemplo n.º 29
0
def index():
    form = InputForm(request.form)
    if request.method == 'POST' and form.validate():
        chart = hentSkred(form.veg.data, form.fylke.data)
        chart = chart.render_data_uri()
    else:
        chart = None

    return render_template('chart1.html', form=form, chart=chart)
Ejemplo n.º 30
0
def index():
    form = InputForm(request.form)
    if request.method == 'POST' and form.validate():
        result = compute(form.Formula.data, form.Domain.data,
                         form.Erase.data)
    else:
        result = None

    return render_template('view.html', form=form, result=result)
Ejemplo n.º 31
0
def index():
    form = InputForm(request.form)
    if request.method == 'POST' and form.validate():
        result = give_me_the_number(form.Team1.data, form.Team1_League.data,
                         form.Team2.data, form.Team2_League.data)
    else:
        result = None
    return render_template('view_plain.html',
                           form=form, result=result)
Ejemplo n.º 32
0
def index():
    form = InputForm(request.form)
    if request.method == 'POST' and form.validate():
        result = compute(form.A.data, form.b.data,
                         form.w.data, form.T.data)
    else:
        result = None

    return render_template('view_plain.html', form=form, result=result)
Ejemplo n.º 33
0
def index():
    form = InputForm(request.form)
    if request.method == 'POST' and form.validate():
        for field in form:
            exec('{} = {}'.format(field.name, field.data))
        result = timeline()
    else:
        result = None

    return render_template(template_name + '.html', result=result)
Ejemplo n.º 34
0
def bookcrossing():
    form = InputForm(request.form)
    if request.method == 'POST': 
        if form.validate() and form.user_id.data > 0 and form.user_id.data < 501 and form.top_cnt.data > 0 and form.top_cnt.data < 68736:
            result = recommend_bx(form.user_id.data, form.top_cnt.data)
            flash('Top %d' % form.top_cnt.data + ' rekomendacji dla użytkownika %d' % form.user_id.data)
            return render_template('bookcrossing.html', form=form, result=result.to_html(classes='skin'))
        else:
            flash('Podaj poprawny ID użytkownika i ilość rekomendacji')
            
    return render_template('bookcrossing.html', form=form)
Ejemplo n.º 35
0
def index():
    form = InputForm(request.form)
    if request.method == 'POST' and form.validate():
        for field in form:
            # Make local variable (name field.name)
            exec('%s = %s' % (field.name, field.data))
        result = compute(A, b, w, T)
    else:
        result = None

    return render_template('view.html', form=form, result=result)
Ejemplo n.º 36
0
def index():
    form = InputForm(request.form)
    if request.method == 'POST' and form.validate():
        for field in form:
            # Make local variable (name field.name)
            exec('%s = %s' % (field.name, field.data))
        result = compute(A, b, w, T)
    else:
        result = None

    return render_template(template, form=form, result=result)
Ejemplo n.º 37
0
def index():
    form = InputForm(request.form)
    if request.method == 'POST' and form.validate():
        result = compute(form.A.data, form.B.data,
                         form.C.data, form.D.data,
                         form.E.data, form.F.data)
    else:
        result = None

    #return render_template('view_errcheck.html', form=form, result=result)
    return render_template('view_ttl.html', form=form, result=result)
Ejemplo n.º 38
0
def movielens():
    form = InputForm(request.form)
    if request.method == 'POST':    
        if form.validate() and form.user_id.data > 0 and form.user_id.data < 944 and form.top_cnt.data > 0 and form.top_cnt.data < 1683:
            result = recommend_mv(form.user_id.data, form.top_cnt.data)
            flash('Top %d' % form.top_cnt.data + ' rekomendacji dla użytkownika %d' % form.user_id.data)
            return render_template('movielens.html', form=form, result=result.to_html(classes='skin'))
        else:
            flash('Podaj poprawny ID użytkownika i ilość rekomendacji')
    
    return render_template('movielens.html', form=form)
Ejemplo n.º 39
0
def index():
    # breast-cancer prediction
    formbreastcancer = InputForm(request.form)
    if request.method == 'POST' and formbreastcancer.validate():
        result = compute(formbreastcancer.a.data, formbreastcancer.b.data,
                         formbreastcancer.c.data, formbreastcancer.d.data,
                         formbreastcancer.e.data, formbreastcancer.z.data,
                         formbreastcancer.g.data, formbreastcancer.h.data,
                         formbreastcancer.i.data)
    else:
        result = None
    return render_template('index2.html', form=formbreastcancer, result=result)
Ejemplo n.º 40
0
def index():
    form = InputForm(request.form)
    if request.method == "POST" and form.validate():
        arg_names = inspect.getargspec(compute).args
        kwargs = {name: getattr(form, name).data for name in arg_names if hasattr(form, name)}
        result = compute(**kwargs)
    else:
        result = None
    if result:
        # result must be transformed to HTML and inserted as a
        # string in the generic view.html file
        result = render_template("view_results.html", result=result)
    return render_template("view.html", form=form, result=result)
Ejemplo n.º 41
0
def index():
    form = InputForm(request.form)
    if request.method == 'POST' and form.validate():
        for field in form:
            exec('%s = %s' % (field.name, field.data))
        variable = dict(CHOICES).get(form.variable.data)

        result = plot(form.lon_w.data, form.lon_e.data, form.lat_s.data, form.lat_n.data, variable,
                      form.point_check.data, form.title.data, form.color_bar.data)

    else:
        result = None

    return render_template(template, form=form, result=result)
Ejemplo n.º 42
0
def index():
    form = InputForm(request.form)
    if request.method == 'POST' and form.validate():
        result = compute(form.A.data, form.b.data,
                         form.w.data, form.T.data)
    else:
        result = None
    print form, dir(form)
    #print form.keys()
    for f in form:
        print f.id
        print f.name
        print f.label

    return render_template(template_name + '.html',
                           form=form, result=result)
Ejemplo n.º 43
0
def index():
    form = InputForm(request.form)
    if request.method == 'POST' and form.validate():
        result = compute(formula=form.Formula.data,
                         independent_variable=form.Variable.data,
                         N=form.N.data,
                         xmin=form.xmin.data,
                         xmax=form.xmax.data,
                         ymin=form.ymin.data,
                         ymax=form.ymax.data,
                         legend_loc=form.legend_loc.data,
                         x0=form.x0.data,
                         erase=form.Erase.data)
    else:
        result = None
    print request.method, [field.errors for field in form]

    return render_template('view.html', form=form, result=result)
def index():
    form = InputForm(request.form)
    if request.method == 'POST' and form.validate():
        if form.dims.data < 3:
            raise ValueError("Dimensions should be greater than 2 for a three card SET game")
        if form.dim_size.data < 3:
            raise ValueError("Dimension size should be greater than 2 for a three card SET game")
        s = form.dims.data * [range(form.dim_size.data)]
        possible_cards = len(list(itertools.product(*s)))
        if form.n_cards.data > possible_cards:
            raise ValueError("Number of cards on the deck cannot be greater than %s" %possible_cards)
        game_set = Sets(form.dims.data, form.dim_size.data, form.n_cards.data)
        if form.dim_size.data == 3:
            result = game_set.get_sets()
        else:
            result = game_set.getsets_brute()
    else:
        result = None

    return render_template('view.html', form=form, result=result)
Ejemplo n.º 45
0
def index():
    form = InputForm(request.form)
    if request.method == 'POST' and form.validate():
        arg_names = inspect.getargspec(compute).args
        kwargs = {name: getattr(form, name).data
                  for name in arg_names if hasattr(form, name)}
        result = compute(**kwargs)
    else:
        result = None
    # Concatenate view_forms.html and view_results.html
    forms_html   = os.path.join('templates', 'view_forms.html')
    results_html = os.path.join('templates', 'view_results.html')
    view_html    = os.path.join('templates', 'view.html')
    f_forms = open(forms_html, 'r')
    f_res   = open(results_html, 'r')
    f_view  = open(view_html, 'w')
    f_view.write(f_forms.read() + f_res.read())
    f_forms.close();  f_res.close();  f_view.close()
    return render_template(os.path.basename(view_html),
                           form=form, result=result)
Ejemplo n.º 46
0
def index():
    form = InputForm(request.form)
    if request.method == 'POST' and form.validate():
        arg_names = inspect.getargspec(compute).args
        kwargs = {name: getattr(form, name).data
                  for name in arg_names if hasattr(form, name)}
        # Run eval on the text
        # Note that form.name.label is <label for="A">(list)</label>
        for name in kwargs:
            if hasattr(form, name) and \
                   hasattr(getattr(form, name), 'label'):
                label = str(getattr(form, name).label)
                for tp in ('(list)', '(tuple)', '(nd.array)'):
                    if tp in label:
                        kwargs[name] = eval(kwargs[name])

        result = compute(**kwargs)
    else:
        result = None
    if result:
        # result must be transformed to HTML and inserted as a
        # string in the generic view.html file
        result = render_template('view_results.html', result=result)
    return render_template('view.html', form=form, result=result)