#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Copyright (C) 2014 Canonical
#
# Authors:
#  Didier Roche
#
# This program is free software; you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free Software
# Foundation; version 3.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
# details.
#
# You should have received a copy of the GNU General Public License along with
# this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA

import logging
import os
import sys
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "..")))
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), "..")))
import sys
from tools import get_data_dir
from tools.local_server import LocalHttp


logging.basicConfig(level=logging.DEBUG,
                    format="%(asctime)s [%(name)s] %(levelname)s: %(message)s")


# start a connection
hostname = sys.argv[2]
ftp_redir = (sys.argv[2].lower() == 'true')
server_dir = os.path.join(get_data_dir(), "server-content")

LocalHttp(server_dir, multi_hosts=True, port=int(sys.argv[1]), use_ssl=sys.argv[3:], ftp_redir=ftp_redir)
