From 581cf5d8dd832f60c7d953bf0e9a5e524bf1b3a8 Mon Sep 17 00:00:00 2001 From: Steven Date: Fri, 15 Oct 2021 16:29:19 -0400 Subject: [PATCH 1/4] cli option --- qbay/__main__.py | 22 +++++++++++++++++++++- qbay/cli.py | 19 +++++++++++++++++++ 2 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 qbay/cli.py diff --git a/qbay/__main__.py b/qbay/__main__.py index f08984c..5c6e481 100644 --- a/qbay/__main__.py +++ b/qbay/__main__.py @@ -1,2 +1,22 @@ from qbay import * -from qbay.models import * \ No newline at end of file +from qbay.cli import login_page, regsiter_page + + +def main(): + while True: + selection = input( + 'Welcome. Please type 1 to login. Or type 2 register.') + 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() + + +if __name__ == '__main__': + main() diff --git a/qbay/cli.py b/qbay/cli.py new file mode 100644 index 0000000..e54fb05 --- /dev/null +++ b/qbay/cli.py @@ -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 succceeded') + else: + print('regisration failed.') From 501849b757e7a5a738d7f658ea7e4c442202a4c2 Mon Sep 17 00:00:00 2001 From: Shenghao Jin <55732335+Altered-Si@users.noreply.github.com> Date: Fri, 22 Oct 2021 19:14:12 -0400 Subject: [PATCH 2/4] Fix a spelling error at Line 17 --- qbay/cli.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qbay/cli.py b/qbay/cli.py index e54fb05..2633197 100644 --- a/qbay/cli.py +++ b/qbay/cli.py @@ -14,6 +14,6 @@ def regsiter_page(): if password != password_twice: print('password entered not the same') elif register('default name', email, password): - print('registration succceeded') + print('registration succeeded') else: print('regisration failed.') From 2511674039d85b8627cb5cf16ac2c821bd255612 Mon Sep 17 00:00:00 2001 From: steven Date: Thu, 6 Oct 2022 02:57:00 -0400 Subject: [PATCH 3/4] fix context & add exit --- qbay/__init__.py | 1 + qbay/__main__.py | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/qbay/__init__.py b/qbay/__init__.py index d2a1cb4..103608f 100644 --- a/qbay/__init__.py +++ b/qbay/__init__.py @@ -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() diff --git a/qbay/__main__.py b/qbay/__main__.py index 5c6e481..b74d0f1 100644 --- a/qbay/__main__.py +++ b/qbay/__main__.py @@ -5,7 +5,7 @@ def main(): while True: selection = input( - 'Welcome. Please type 1 to login. Or type 2 register.') + 'Welcome. Please type 1 to login. Or type 2 register. Or type 3 to exit') selection = selection.strip() if selection == '1': user = login_page() @@ -16,6 +16,8 @@ def main(): print('login failed') elif selection == '2': regsiter_page() + elif selection == '3': + break if __name__ == '__main__': From a43bee900efce2fd79b6a775bbf08f1f57e78e9c Mon Sep 17 00:00:00 2001 From: steven Date: Thu, 6 Oct 2022 02:59:50 -0400 Subject: [PATCH 4/4] pep8 error --- qbay/__main__.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/qbay/__main__.py b/qbay/__main__.py index b74d0f1..493eda5 100644 --- a/qbay/__main__.py +++ b/qbay/__main__.py @@ -5,7 +5,8 @@ def main(): while True: selection = input( - 'Welcome. Please type 1 to login. Or type 2 register. Or type 3 to exit') + 'Welcome. Please type 1 to login. ' + 'Or type 2 register. Or type 3 to exit') selection = selection.strip() if selection == '1': user = login_page()