def helloWorld():
    form = SimpleForm()
    if form.validate_on_submit():
        lista = form.example.data
        for l in lista:
            print l
    else:
        print form.errors
    return render_template('example.html',form=form)
Exemplo n.º 2
0
def select():
    cards = []
    form = SimpleForm()
    title = 'Рецепт по ингредиентам'
    if form.validate_on_submit():
        #print(form.cb.data)
        n = 0
        cb_data = form.cb1.data + form.cb2.data + form.cb3.data
        #print(cb_data)

        r = Recipe
        q = r.query.all()

        for i in q:
            #print(i.ingridients)
            listt = cb_data  #sel ingr
            ilistt = i.ingridients.split(',')  #rec ingr
            good = True
            for j in ilistt:
                j = j.strip(' ')
                j = j.strip()
                if j != '' and j not in listt:
                    good = False
                    pass
            if good:

                url = i.url
                name = i.name
                url_img = i.url_img
                category = i.category
                ingridients = i.ingridients
                time = 0
                cards.append({
                    "name": name,
                    "url": url,
                    'url_img': url_img,
                    'category': category,
                    'ingridients': ingridients,
                    'time': time
                })

                n += 1
                #print(i)
        q = None
        #print(n)
        #print(cards)
        return render_template('catalog.html',
                               title=title,
                               active='catalog'.lower(),
                               cards=cards)
        #return render_template("success.html", data=cb_data)
    return render_template('select.html',
                           title=title,
                           active='select'.lower(),
                           form=form)
Exemplo n.º 3
0
def simple_form():
    sform = SimpleForm()
    if redis.get("hits") is None:
        redis.set("hits", 0)
    if sform.validate_on_submit():
        redis.incr("hits")
        flash(f"Hi {sform.username.data}")
    return render_template("simpleform.html",
                           title="Simple Form",
                           form=sform,
                           hits=int(redis.get("hits")))
Exemplo n.º 4
0
def simple_form_view(request):
    form = SimpleForm()

    if request.method == 'POST':  # it is created by sk
        form = SimpleForm(request.POST)
        if form.is_valid():
            #form.save()
            #title = form.cleaned_data['title']

            print(form.cleaned_data['title'])
            print(form.cleaned_data['description'])
            #print(form.cleaned_data['wiki'])

            #return HttpResponse('%s successfully  saved!' % title)
            return HttpResponse('successfully  saved!')
    else:
        context = {'form': form, 'title': 'Simple Form'}

    context = {'form': form, 'title': 'Simple Form'}
    return render(request, 'custom_form.html', context)
Exemplo n.º 5
0
def simple_form_view(request):
    form = SimpleForm()
    context = {'form': form, 'title': 'Simple Form'}
    return render(request, 'base.html', context)
Exemplo n.º 6
0
def simple_form_view(request):
    form = SimpleForm()
    context = {'form': form, 'title': 'Simple Form'}
    theme = getattr(settings, 'MARTOR_THEME', 'bootstrap')
    return render(request, '%s/form.html' % theme, context)
Exemplo n.º 7
0
def hello_world():
    form = SimpleForm()
    if form.validate_on_submit():
        return redirect('/')
    #return render_template('basicform7.html',form=form,buttons=form.fabric,buttons1=form.occasion,buttons2=form.pattern)
    return render_template('basicform9.html', form=form)
Exemplo n.º 8
0
def simple_form_view(request):
    form = SimpleForm()
    context = {"form": form, "title": "Simple Form"}
    theme = getattr(settings, "MARTOR_THEME", "bootstrap")
    return render(request, "%s/form.html" % theme, context)