Die Methode ist nicht erlaubt, die angeforderte URL. im Fläschchen

Schreibe ich in diesem forum und ich möchte überprüfen Benutzername und Passwort, aber ich habe Ergebnis.Methode Nicht Erlaubt

hello.html

HTML:

<html lang='en'>
<head>
    <meta charset="utf-8" />
    <title>Hello</title>

</head>
{% if error %}
    {{ error }}
{% endif %}
<body>

      Hello 

</body>
</html>

Die Methode ist nicht erlaubt, die angeforderte URL.

<!DOCTYPE html>
<!--[if (gte IE 9)|!(IE)]><!--> <html lang="en"> <!--<![endif]-->
<head>
<meta charset="utf-8">
<title>welcome</title>
<link href="{{ url_for('static', filename='style.css') }}" rel="stylesheet" type="text/css" />
</head>
<body>
<div class="container">
    <section id="content">
        <form action="/login" method="post">
            <h1>Login Form</h1>
            <div>
                <input type="text" placeholder="Username" required=""  name="username" />
            </div>
            <div>
                <input type="password" placeholder="Password" required="" name="password" />
            </div>
            <div>
                <input type="submit" value="Log in"  />

            </div>
        </form><!-- form -->

    </section><!-- content -->

</div><!-- container -->
</body>
</html>

Schreibe ich ein forum:

in app.py:

from flask import Flask
from flask import request
from flask import render_template, redirect, url_for, request
APP = Flask(__name__)
@APP.route('/')
def login1():
      return render_template('login1.html')
@APP.route('/login', methods=['GET', 'POST'])
def login():
    error = None
    if request.method == 'POST':
        if request.form['username'] != 'admin' or request.form['password'] != 'admin':
            error = 'Invalid Credentials. Please try again.'
        else:
            return redirect(url_for('home'))
   return render_template('hello.html', error=error)

if __name__ == '__main__':
      APP.debug=True
      APP.run()

Kann ich nicht validieren, den input?
wie kann mir bitte helfen

  • versuchen @APP.route('/?', methods=['GET', 'POST']) zu @APP.route('/login', methods=['GET', 'POST']).und in htmlform action="/login"
  • Ich habe das gleiche Ergebnis
  • Haben Sie sich verändert in beiden app.py und html ?
  • ja, ich Tat, was Sie sagte zu mir @itzmeontv
  • check meine Antwort
InformationsquelleAutor malek tio | 2015-04-05
Schreibe einen Kommentar