Просмотр исходного кода

Updating the script because of login.py

SnowCode 5 лет назад
Родитель
Сommit
4ef5587611
2 измененных файлов с 4 добавлено и 11 удалено
  1. 3 2
      app.py
  2. 1 9
      helper.py

+ 3 - 2
app.py

@@ -3,8 +3,9 @@ from login import * # import the login helper file
 import helper, json, time # Import the helper file and other modules
 import helper, json, time # Import the helper file and other modules
 app = Flask(__name__) # Create the app
 app = Flask(__name__) # Create the app
 db = helper.createDb(app) # Get the database
 db = helper.createDb(app) # Get the database
-User, Topic, Reply, db = db['User'], db['Topic'], db['Reply'], db['db'] # Get the classes
-createLoginManager(app, User) # Create and init the login manager (login helper file)
+Topic, Reply, db = db['Topic'], db['Reply'], db['db'] # Get the classes
+User = initLogin(app, db) # Create and init the login manager (login helper file)
+db.create_all()
 def getTime(): return time.asctime( time.localtime(time.time()) ) # Get the current time and date
 def getTime(): return time.asctime( time.localtime(time.time()) ) # Get the current time and date
 
 
 @app.route('/login') # Render the login page, nothing more
 @app.route('/login') # Render the login page, nothing more

+ 1 - 9
helper.py

@@ -9,13 +9,6 @@ def createDb(app):
 	db = SQLAlchemy(app)
 	db = SQLAlchemy(app)
 
 
 	# Create the tables
 	# Create the tables
-	class User(UserMixin, db.Model):
-			id = db.Column(db.Integer, primary_key=True)
-			username = db.Column(db.Text, unique=True)
-			password = db.Column(db.Text)
-			def __init__(self, username, password):
-				self.username = username
-				self.password = password
 	class Topic(db.Model):
 	class Topic(db.Model):
 	        id = db.Column(db.Integer, primary_key=True)
 	        id = db.Column(db.Integer, primary_key=True)
 	        title = db.Column(db.Text)
 	        title = db.Column(db.Text)
@@ -86,7 +79,6 @@ def createDb(app):
 	                l.append(username)
 	                l.append(username)
 	                self.likesNum += 1
 	                self.likesNum += 1
 	                self.likes = json.dumps(l)
 	                self.likes = json.dumps(l)
-	db.create_all()
 
 
 	# Return the data
 	# Return the data
-	return {'db': db, 'User': User, 'Topic': Topic, 'Reply': Reply}
+	return {'db': db, 'Topic': Topic, 'Reply': Reply}