#!/usr/bin/python3

import os
import yaml

if os.path.exists("config.yaml"):
    with open("config.yaml", "r") as f:
        config = yaml.safe_load(f)

    os.system(f"/root/.cargo/bin/agate --content {config['content']} --addr [::]:1965 --addr 0.0.0.0:1965 --hostname {config['hostname']} --lang en-US")

else:
    content = input("What is the path to content: ")
    hostname = input("What is the hostname that you would like to use: ")

    config_yml = f"content: {content}\nhostname: {hostname}"

    yml = yaml.safe_load(config_yml)

    with open("config.yaml", "w") as f:
        yaml.dump(yml, f)

    os.system(f"/root/.cargo/bin/agate --content {content} --addr [::]:1965 --addr 0.0.0.0:1965 --hostname {hostname} --lang en-US")
