-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathapp.py
38 lines (34 loc) · 1.15 KB
/
app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
from getpass import getpass
import sys
from flaskie.api.v1.auth.errors import check_valid_email
from flaskie.api.v2.models import User
from flaskie import create_app
from flaskie import settings, log
from migrate import Migration
migrate = Migration()
app = create_app(settings.DEVELOPMENT)
@app.cli.command()
def createsuperuser():
with app.app_context():
log.info('Creating superuser.....')
counter = 0
name = input('Enter name: ')
username = input('Enter username: ')
email = input('Enter email: ')
password = getpass('Enter password: ')
try:
assert password == getpass('Confirm password: ')
except AssertionError as e:
print('The password did match, try again')
return
if check_valid_email(email) is None:
print('Not a valid email address, please try again')
return
else:
user = User(name, username, email, password, admin=True)
user.insert()
print('Admin created successfully')
if __name__ == "__main__":
# migrate.tear_down()
migrate.set_up()
app.run(debug=settings.FLASK_DEBUG)