python - Bad Request with Flask -


really struggling bad request flask. know caused flask not finding [key] in form.. however, i've checked form , python code 40 times , cannot see reason case.. have commented out each line of python code references request.form. have done 1 1 , still bad request. when comment out lines bad request goes away.. thought wonderful..

python code;

if request.method == 'post':     form = 'add package form'     clientid = request.form['id']     date = request.form['date2']     strprice = request.form['price']     price = float(strprice)     adultlessons = request.form['adult']     juniorlessons = request.form['junior']     shortlessons = request.form['short']     playinglessons = request.form['playing']     notes = request.form['notes'] 

form..

<form action="/addpackage" method="post" class="sky-form">                 <fieldset>                 <section>                     <label class="label">select package date</label>                         <label class="input">                         <i class="icon-append fa fa-calendar"></i>                         <input type="text" name="date2" id="date">                     </label>                 </section>                 <div style="margin: -25px"></div>             <fieldset>                 <section>                     <label class="label">price</label>                     <label class="input">                         <input type="text" name="price">                     </label>                 </section>                 <section>                     <label class="label">adult lessons</label>                     <label class="input">                         <input type="text" name="adult">                     </label>                 </section>                 <section>                     <label class="label">junior lessons</label>                     <label class="input">                         <input type="text" name="junior">                     </label>                 </section>                 <section>                     <label class="label">short game lessons</label>                     <label class="input">                         <input type="text" name="short">                     </label>                 </section>                 <section>                     <label class="label">playing lessons</label>                     <label class="input">                         <input type="text" name="playing">                     </label>                 </section>                 <section>                     <label class="label">notes</label>                     <label class="textarea textarea-expandable">                         <textarea rows="3" name="notes"></textarea>                     </label>                     <div class="note"><strong>note:</strong> expands on focus.</div>                 </section>             </fieldset>                 </fieldset>             <!-- hidden client id -->             <input type="hidden" name="id" value="{{ client.id }}">             <!-- /hidden client id -->             <footer>                 <button type="submit" name="addpackage" value="package" class="button">add package</button>             </footer>         </form> 

this of half-answer, long comment.

if enable debugging in flask app should detailed traceback indicating problem occurring (both in browser , on console).

if application has like:

app.run() 

just set debug parameter true:

app.run(debug=true) 

if after enabling debugging you're still not sure what's causing problem, update question include traceback.

for it's worth, if dump form , code simple flask app, seems work fine as long provide numeric value price field.


Comments

Popular posts from this blog

java - SSE Emitter : Manage timeouts and complete() -

jquery - uncaught exception: DataTables Editor - remote hosting of code not allowed -

java - How to resolve error - package com.squareup.okhttp3 doesn't exist? -