-
Notifications
You must be signed in to change notification settings - Fork 0
/
runserver.py
41 lines (30 loc) · 1.03 KB
/
runserver.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
39
40
41
import sys
if len(sys.argv) > 1:
if sys.argv[1] == 'user':
from spice.models import User
from spice.database import db_session
name = input('User name: ')
password = input('Password: ')
user = User(name, password)
db_session.add(user)
db_session.commit()
print('User created: %r' % user.id)
if sys.argv[1] == 'init_db':
from spice import app
from spice.database import init_db
init_db()
print("Database init")
if sys.argv[1] == 'process':
from spice.models import File
from spice.database import db_session
from spice.handlers import get_handler_instance
files = db_session.query(File).order_by(File.id.desc()).all()
for record in files:
handler = get_handler_instance(record)
handler.process()
db_session.add(handler.record)
db_session.commit()
else:
from spice import app
app.run(debug=True, host='0.0.0.0', port=3000)
import spice.views