<commit_before>extern crate hyper;

use std::env;
use std::thread;
use std::collections::HashMap;

use self::hyper::server;

use http::dispatcher::Dispatcher;
use http::app::App;

pub struct Server {
    pub thread: thread::JoinHandle<()>,
}

impl Server {
    pub fn create() -> Server {
        let thread = Server::create_thread();

        Server{
            thread: thread,
        }
    }

    fn create_thread() -> thread::JoinHandle<()> {
        thread::spawn(move || {
            let app_home = env::var("ZAS_HOME").unwrap();

            let mut apps = HashMap::new();
            apps.insert("simple".to_string(), App::new("simple", "12050", &app_home));
            apps.insert("other".to_string(), App::new("other", "12051", &app_home));

            let dispatcher = Dispatcher::new(apps);

            server::Server::http("127.0.0.1:12044").unwrap().handle(dispatcher).unwrap();
        })
    }
}
<commit_msg>feature: Default ZAS_HOME to ~/.zas if it is not defined<commit_after>extern crate hyper;

use std::env;
use std::thread;
use std::collections::HashMap;

use self::hyper::server;

use http::dispatcher::Dispatcher;
use http::app::App;

const DEFAULT_APP_HOME: &'static str = "~/.zas";

pub struct Server {
    pub thread: thread::JoinHandle<()>,
}

impl Server {
    pub fn create() -> Server {
        let thread = Server::create_thread();

        Server{
            thread: thread,
        }
    }

    fn create_thread() -> thread::JoinHandle<()> {
        thread::spawn(move || {
            let app_home = env::var("ZAS_HOME").unwrap_or(DEFAULT_APP_HOME.to_string());

            let mut apps = HashMap::new();
            apps.insert("simple".to_string(), App::new("simple", "12050", &app_home));
            apps.insert("other".to_string(), App::new("other", "12051", &app_home));

            let dispatcher = Dispatcher::new(apps);

            server::Server::http("127.0.0.1:12044").unwrap().handle(dispatcher).unwrap();
        })
    }
}

{'fraction_non_alphanumeric': 0.17507568113017155, 'fraction_numerical': 0.02119071644803229, 'mean_word_length': 2.9345238095238093, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '722740', 'n_tokens_mistral': 645, 'n_tokens_neox': 615, 'n_words': 126}