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

"""API server, with a web client for free"""

# System modules
import time

# Third-party modules
from flask import Flask, request
from web.server import instance

app = Flask(__name__)

if __name__ == "__main__":

    # System modules
    import sys

    with_web = True
    try:
        arg = sys.argv[1]
        if arg.startswith("--noweb"):
            with_web = False
            port = 5533
        else:
            port = arg
    except IndexError as e:
        port = 5533

    hostname = "0.0.0.0"

    print(f"hostname {hostname}")
    
    socketio = instance.enable(app)
    socketio.run(app, host=hostname, port=port)
