-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathTheArk.py
40 lines (34 loc) · 1.26 KB
/
TheArk.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
#!/usr/bin/env python3
import os
from theark import app
from theark.database import Database
from theark.hosts import Hosts
def setup():
"""Setup all the variables and run all the actions needed for The Ark to run
1. Open a database, create it if necessary
2. Find the original IP of the host
"""
# Import the routes
# Open a database
db_name = os.environ.get("ARK_DATABASE", "files/theark.sqlite")
config = os.environ.get("ARK_CONFIG", "config.yml")
app.config['DATABASE'] = Database(db_name, 'files/layout.sql')
app.config['HOSTS'] = Hosts(config, app.config['DATABASE'])
from theark import routes, api # pylint: disable=w0612
def cleanup():
"""Delete all the virtual interfaces for the machine
TODO: Delete all the virtual interfaces for the machine
"""
app.config['DATABASE'].close()
if __name__ == "__main__":
setup()
host = os.environ.get("FLASK_HOST", "0.0.0.0")
try:
port = os.environ.get("FLASK_PORT", "80")
port = int(port)
except ValueError:
port = 5000
debug = os.environ.get("FLASK_DEBUG", "False")
debug = debug.lower().strip() in ["true", "yes", "1", "t"]
app.run(debug=debug, host=host, port=port)
cleanup()