-
Notifications
You must be signed in to change notification settings - Fork 3
/
core-runnner.py
executable file
·55 lines (40 loc) · 1.4 KB
/
core-runnner.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
""" fontman desktop core
fontman client font management system main application script.
Created by Lahiru Pathirage @ Mooniak<[email protected]> on 3/12/2016
"""
from blueprint import auth_blueprint
from blueprint import collections_blueprint
from blueprint import fontfaces_blueprint
from blueprint import fonts_blueprint
from blueprint import settings_blueprint
from blueprint import typecase_blueprint
from utility import FileManager
from utility import initialize
from utility import run_tasks
import socket
import threading
from flask import Flask
def run_flask_app():
fms = Flask(__name__)
fms.register_blueprint(auth_blueprint)
fms.register_blueprint(collections_blueprint)
fms.register_blueprint(fontfaces_blueprint)
fms.register_blueprint(fonts_blueprint)
fms.register_blueprint(settings_blueprint)
fms.register_blueprint(typecase_blueprint)
fms.run(host="0.0.0.0", threaded=True)
def main():
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
con = sock.connect_ex(('127.0.0.1', 5000))
if con is not 0:
if FileManager().is_file_exists("./data/fontman.db"):
threading.Thread(target=run_tasks).start()
run_flask_app()
else:
initialize()
threading.Thread(target=run_tasks).start()
run_flask_app()
else:
print("Port is in use.")
if __name__ == '__main__':
main()