import sys, os
from os import environ
from logging.config import dictConfig
from flask import Flask
from flask_cors import CORS

try:
    from service.uid_service import uid_gen
except:
    from .service.uid_service import uid_gen

dictConfig({
    'version': 1,
    'formatters': {'default': {
        'format': '[%(asctime)s] %(levelname)s in %(module)s: %(message)s',
    }},
    'handlers': {'wsgi': {
        'class': 'logging.StreamHandler',
        'stream': 'ext://flask.logging.wsgi_errors_stream',
        'formatter': 'default'
    }},
    'root': {
        'level': 'INFO',
        'handlers': ['wsgi']
    }
})

app = Flask(__name__)
CORS(app)
app.register_blueprint(uid_gen)

if __name__ == "__main__":
    HOST = environ.get('FLASK_RUN_HOST', 'localhost')
    try:
        PORT = int(environ.get('FLASK_RUN_PORT', '5003'))
    except ValueError:
        PORT = 5003

    app.run(HOST, PORT)

import sys, os
from os import environ
from logging.config import dictConfig
from flask import Flask
from flask_cors import CORS

try:
    from service.uid_service import uid_gen
except:
    from .service.uid_service import uid_gen

dictConfig({
    'version': 1,
    'formatters': {'default': {
        'format': '[%(asctime)s] %(levelname)s in %(module)s: %(message)s',
    }},
    'handlers': {'wsgi': {
        'class': 'logging.StreamHandler',
        'stream': 'ext://flask.logging.wsgi_errors_stream',
        'formatter': 'default'
    }},
    'root': {
        'level': 'INFO',
        'handlers': ['wsgi']
    }
})

app = Flask(__name__)
CORS(app)
app.register_blueprint(uid_gen)

if __name__ == "__main__":
    HOST = environ.get('FLASK_RUN_HOST', 'localhost')
    try:
        PORT = int(environ.get('FLASK_RUN_PORT', '5003'))
    except ValueError:
        PORT = 5003

    app.run(HOST, PORT)
