#!/usr/bin/env python
# -*- coding: utf-8 -*-

from flask import Flask
from apis import api_blueprint, web_blueprint
from werkzeug.exceptions import HTTPException
#from util import exception
# from utils.logger import log
from apis.scheduler import this_scheduler
import logging

app = Flask(__name__)
app.register_blueprint(api_blueprint, url_prefix='/api')
app.register_blueprint(web_blueprint, url_prefix='/web')

app.template_folder = "/opt/tan/lib/python/site-packages/shins/panel/pages"
app.static_folder = "/opt/tan/lib/python/site-packages/shins/panel/static"

this_scheduler.init_app(app)
this_scheduler.start()

if __name__ == "__main__":
    import sys
    import socket
    
    try:
        port = sys.argv[1]
    except IndexError:
        print("using default port")
        port = 5001
        
    hostname = socket.getfqdn()
    app.run(host=hostname, port=port, threaded=True, debug=False)
