-
Notifications
You must be signed in to change notification settings - Fork 0
/
run-server.py
executable file
·100 lines (92 loc) · 3.15 KB
/
run-server.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#!/usr/bin/env python
import sys
import os
from flask import Flask, redirect, url_for
# ensure lpm is found and can be directly imported from this file
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))
import lpm
app = Flask(__name__)
app.config.update(
DEBUG=True,
SECRET_KEY=b'2E\x9d\xe8"\xb5\xa3\x1b\xc5a6\xd8\x12:\x1ea\xf6\x91N[\xe4X\x8e\x8a',
MONGO_DBNAME='lpm',
LPM_AUTH_SRC='simple',
LPM_AUTH_USERS={
'worker': dict(
name='Worker',
password='1234',
roles={'login', 'component_edit'},
active=True,
),
'admin': dict(
name='Admin',
password='1234',
roles={
'login', 'request_login',
'component_edit', 'component_admin',
'stock_admin', 'item_admin', 'db_debug',
},
active=True,
),
'viewer': dict(
name='Viewer',
password='1234',
roles={'login'},
active=True,
),
'disabled': dict(
name='Disabled User',
password='1234',
roles={'login', 'component_admin'},
active=False,
),
'ext': dict(
name='External Scripts',
password='1234',
roles={'request_login', 'component_admin'},
active=True,
)
},
LPM_PARTNO_PREFIX='LP',
LPM_COMPONENT_FILES_DIR='/tmp',
LPM_COMPONENT_CATEGORIES=['category 1', 'category 2'],
LPM_ITEM_VIEW_MAP={
'LP0002': 'LP0002.html',
},
LPM_ITEM_IMPORT_MAP={
'LP0002': dict(
required_fields=['param1'],
integer_fields=['param2'],
),
'LP0001a': dict(
required_fields=['param5'],
date_fields=['param5'],
integer_fields=['param2', 'param6'],
floating_point_fields=['param7'],
boolean_fields=['param8']
)
},
LPM_ITEM_STATUS_MAP={
'LP0002': {
'tested': dict(origins=[''], unavailable=False, role='item_admin'),
'reserved': dict(origins=['', 'tested'], unavailable=False),
'shipped': dict(origins=['reserved'], unavailable=True, require_admin=False),
'obsolete': dict(origins=['', 'tested', 'reserved', 'shipped'],
unavailable=True, role='item_admin')
},
'default': {
'obsolete': dict(origins=[''], unavailable=True, role='item_admin')
},
},
LPM_EXT_UPDATE_FIELDS={
'default': set(),
},
)
lpm.init(app)
@app.route('/')
def main():
"""
main entry point, redirect to the items overview
"""
return redirect(url_for('items.overview'))
app.run()