Всем привет,пытаюсь сделать регистрацию на сайте и возникает ошибка Method Not Allowed
The method is not allowed for the requested URL.
код в reg.py
from werkzeug.security import generate_password_hash
from flask import Flask, render_template, url_for, request
from flask_sqlalchemy import SQLAlchemy
from datetime import datetime
app = Flask(__name__)
app.config["SQLALCHEMY_DATABASE_URI"] = "sqlite:///project.db"
app.config["SQLALCHEMY_TRACK_MODIFICATION"] = False
db = SQLAlchemy(app)
class User(db.Model):
id = db.Column(db.Integer, primary_key=True)
username = db.Column(db.String, nullable=False)
psw = db.Column(db.String(20), nullable=False)
email = db.Column(db.String, nullable=False)
date = db.Column(db.DateTime, default=datetime.utcnow)
def __repr__(self):
return f'ID={self.id},Name={self.username}'
with app.app_context():
db.create_all()
@app.route('/bs')
def bs():
return render_template("bs.html")
@app.route("/voiti", method=['POST','GET'])
def voiti():
if request.method=="POST":
try:
hash=generate_password_hash(request.form['pass'])
u=User(username=request.form['name'],email=request.form['email'],psw=hash)
db.session.add(u)
db.session.flush()
db.session.commit()
except:
db.session.rollback()
print("Ошибка добавления записи в базу данных")
return render_template("voiti.html")
if( __name__=='__main__'):
app.run(debug=False)
код в voiti.html
{% extends 'base.html' %}
{% block title %}
Регистрация
{% endblock %}
{% block body %}
<div class="container">
<div class="row">
<div class="col-6">
<form action="/voiti" method="post" class="p-5 grey-text">
<div class="md-form form-sm">
<input type="text" name="name" class="form-control form-control-sm" placeholder="Введите имя">
</div>
<div class="md-form form-sm">
<input type="email" name="email" class="form-control form-control-sm" placeholder="Введите логин">
</div>
<div class="md-form form-sm">
<input type="password" name="pass" class="form-control form-control-sm" placeholder="Введите пароль">
</div>
<div class="text-center mt-4">
<button type="submit" class="btn btn-info">Войти</button>
</div>
<div class="text-center mt-4">
<button type="button" class="btn btn-light"><a href="#">Зарегистрироваться</a></button>
</div>
</form>
</div>
</div>
</div>
{% endblock %}
Полдня ушло,но так и не смог найти ошибку