summaryrefslogtreecommitdiff
path: root/ickapi/main.py
blob: c40bf229cebc46a474610fe91c4302293fc539b4 (plain)
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
"""Main module.

A web server application that can be passed to gunicorn. Also works as
standalone program (run from project root):

    python ickapi/main.py --host 127.0.0.1 --port 8080
"""

import argparse
import logging

import aiohttp

import ickapi

DEFAULT_HOST = '127.0.0.1'
DEFAULT_PORT = 8080

app = ickapi.create_app()


def main():
    """Run a standalone development server."""
    logging.basicConfig(level=logging.INFO)

    parser = argparse.ArgumentParser()
    parser.add_argument('--host', default=None)
    parser.add_argument('--port', type=int, default=0)

    args = parser.parse_args()
    host = args.host or DEFAULT_HOST
    port = args.port or DEFAULT_PORT

    aiohttp.web.run_app(app, host=host, port=port)


if __name__ == '__main__':
    main()