Skip to content
Snippets Groups Projects

Resolve "creating database flask-sqlalchemy"

1 file
+ 21
0
Compare changes
  • Side-by-side
  • Inline
+ 21
0
@@ -16,6 +16,7 @@ class User(db.Model):
name = db.Column(db.String(255), nullable=False)
email = db.Column(db.String(255), nullable=False)
pwd = db.Column(db.String(255), nullable=False)
role = db.Column(db.String(255), nullable=False)
class Salamander(db.Model):
@@ -86,6 +87,26 @@ class FindSalamanderInfo(Resource):
return output
class RegisterUser(Resource):
@staticmethod
def post():
output = {"message": "something went wrong"}
data = request.form
if not data['name'] or not data['email'] or not data['password'] or not data['confirmPassword']:
output = {"message": "data is incorrect"}
else:
if data['password'] == data['confirmPassword']:
user = User(name=data['name'], email=data['email'], pwd=data['password'], role='pending')
db.session.add(user)
db.session.commit()
output = {"message": "user added"}
return output
api.add_resource(RegisterUser, "/registerUser")
api.add_resource(MatchSalamander, "/matchSalamander")
api.add_resource(FindSalamanderInfo, "/findSalamanderInfo")
Loading