Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions qbay/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@
app = Flask(__name__)
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///../db.sqlite'
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
app.app_context().push()
25 changes: 24 additions & 1 deletion qbay/__main__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,25 @@
from qbay import *
from qbay.models import *
from qbay.cli import login_page, regsiter_page


def main():
while True:
selection = input(
'Welcome. Please type 1 to login. '
'Or type 2 register. Or type 3 to exit')
selection = selection.strip()
if selection == '1':
user = login_page()
if user:
print(f'welcome {user.username}')
break
else:
print('login failed')
elif selection == '2':
regsiter_page()
elif selection == '3':
break


if __name__ == '__main__':
main()
19 changes: 19 additions & 0 deletions qbay/cli.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
from qbay.models import login, register


def login_page():
email = input('Please input email')
password = input('Please input password:')
return login(email, password)


def regsiter_page():
email = input('Please input email:')
password = input('Please input password:')
password_twice = input('Please input the password again:')
if password != password_twice:
print('password entered not the same')
elif register('default name', email, password):
print('registration succeeded')
else:
print('regisration failed.')