Python flask form gives 405 -


i have form , every time try post method in buttom of question. application gives me 405 error directly. have checked database works using same method in console.

(i have removed alot of html because styling , stuff that)

<form action="/register" method="post" class="grid">                                      <div class="cell colspan3" style="margin-left:2%;">                                         <div class="input-control modern text">                                             <input type="email" name="email" id="email">                                             <span class="label">email</span>                                             <span class="informer">skriv din email</span>                                             <span class="placeholder">email</span>                                         </div>                                     </div>                                     <div class="cell colspan3">                                         <div class="input-control modern text cell">                                             <input type="text" name="username" id="username" >                                             <span class="label">brugernavn</span>                                             <span class="informer">skriv dit brugernavn</span>                                             <span class="placeholder">brugernavn</span>                                         </div>                                     </div>                                     <div class="cell colspan3">                                         <div class="input-control modern text cell">                                             <input type="password" name="password" id="password">                                             <span class="label">password</span>                                             <span class="informer">skriv dit password</span>                                             <span class="placeholder">password</span>                                         </div>                                     </div>                                     <div class="cell colspan3">                                         <div class="input-control modern text cell">                                             <input type="password" name="passwordconfirm" id="passwordconfirm">                                             <span class="label">gentag password</span>                                             <span class="informer">skriv dit password igen.</span>                                             <span class="placeholder">gentag password</span>                                         </div>                                     </div>                                      <div class="cell colspan3">                                         <label class="input-control checkbox ">                                             <input type="checkbox" name="accept_tos" id="accept_tos">                                             <span class="check"></span>                                             <span class="caption">jeg accepterer hjemmesidens regler</span>                                         </label>                                     </div>                                     <div class="cell colspan3">                                         <div class="input-control cell">                                             <button class="button success" type="submit">registrer</button>                                         </div>                                     </div>                                 </div>                             </div>              </form> 

the python method call html post form:

 @app.route('/register', methods=['get', 'post']) def register():     form = registrationform(request.form)     if request.method == 'post' , form.validate():         newuser = user(form.username.data, form.email.data, form.password.data)         db.session.add(newuser)         db.session.commit()         return render_template('login.html')     else:         return render_template('register.html') 

and registrationform method looks this:

class registrationform(form):     username = stringfield('username', [validators.length(min=4, max=25)])     email = stringfield('email', [validators.email, validators.length(min=4, max=40)])     password = passwordfield('password',                              [validators.required(),                               validators.equalto('confirm', message='passwords skal matche hinanden.')                               ])     confirm = passwordfield('passwordconfirm')     accept_tos = booleanfield('jeg accepterer regler denne hjemmeside', [validators.required()]) 

obviously there'snt problem in these codes unless have url_prefix current app :

app = blueprint('user', __name__, url_prefix='/user/') 

and u have blueprint url_prefix :

app = blueprint('general', __name__, url_prefix='/') 

with funtion :

@app.route('/register', methods=['get']) 

in blueprint ...

and form posting data '/register' instead of '/user/register'


Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -