#![allow(non_snake_case)]
#![allow(unused_braces)]
use rouille::{router, Response};
use std::fs::File;

fn main() {
	// Never leave the server. CTRL + C if you have issues.
	rouille::start_server("127.0.0.1:5001", move |Request| {	
		// Router. Go to the correct pages, else hit the sack.
		router!(Request,
			// Icons.
			(GET) ["/Icons/ArrowLeft.png"] => {
				Response::from_file("image/png", File::open("src/HTTP/Icons/ArrowLeft.png").unwrap()).with_status_code(200)
			},
			(GET) ["/Icons/ArrowRight.png"] => {
				Response::from_file("image/png", File::open("src/HTTP/Icons/ArrowRight.png").unwrap()).with_status_code(200)
			},
			(GET) ["/Icons/favicon.ico"] => {
				Response::from_file("image/vnd.microsoft.icon", File::open("src/HTTP/Icons/favicon.ico").unwrap()).with_status_code(200)
			},
			(GET) ["/Icons/IndexBackground.png"] => {
				Response::from_file("image/png", File::open("src/HTTP/Icons/IndexBackground.png").unwrap()).with_status_code(200)
			},
			(GET) ["/Icons/IndexBlackBackground.png"] => {
				Response::from_file("image/png", File::open("src/HTTP/Icons/IndexBlackBackground.png").unwrap()).with_status_code(200)
			},
			// Audio.
			(GET) ["/Audio/button-305770.mp3"] => {
				Response::from_file("audio/mpeg", File::open("src/HTTP/Audio/button-305770.mp3").unwrap()).with_status_code(200)
			},
			(GET) ["/Audio/button-pressed-38129.mp3"] => {
				Response::from_file("audio/mpeg", File::open("src/HTTP/Audio/button-pressed-38129.mp3").unwrap()).with_status_code(200)
			},
			(GET) ["/Audio/soft-piano-music-312509.mp3"] => {
				Response::from_file("audio/mpeg", File::open("src/HTTP/Audio/soft-piano-music-312509.mp3").unwrap()).with_status_code(200)
			},
			// JS.
			(GET) ["/JS/index.js"] => { 
				Response::from_file("text/javascript", File::open("src/HTTP/JS/index.js").unwrap()).with_status_code(200)
			},
			(GET) ["/JS/account.js"] => { 
				Response::from_file("text/javascript", File::open("src/HTTP/JS/account.js").unwrap()).with_status_code(200)
			},
			(GET) ["/JS/expanded.js"] => { 
				Response::from_file("text/javascript", File::open("src/HTTP/JS/expanded.js").unwrap()).with_status_code(200)
			},
			(GET) ["/JS/mail.js"] => { 
				Response::from_file("text/javascript", File::open("src/HTTP/JS/mail.js").unwrap()).with_status_code(200)
			},
			(GET) ["/JS/post.js"] => { 
				Response::from_file("text/javascript", File::open("src/HTTP/JS/post.js").unwrap()).with_status_code(200)
			},
			(GET) ["/JS/setting.js"] => { 
				Response::from_file("text/javascript", File::open("src/HTTP/JS/setting.js").unwrap()).with_status_code(200)
			},
			(GET) ["/JS/BlueskyAPI.js"] => { 
				Response::from_file("text/javascript", File::open("src/HTTP/JS/BlueskyAPI.js").unwrap()).with_status_code(200)
			},
			(GET) ["/JS/MastodonAPI.js"] => { 
				Response::from_file("text/javascript", File::open("src/HTTP/JS/MastodonAPI.js").unwrap()).with_status_code(200)
			},
			(GET) ["/JS/TumblrAPI.js"] => { 
				Response::from_file("text/javascript", File::open("src/HTTP/JS/TumblrAPI.js").unwrap()).with_status_code(200)
			},
			(GET) ["/JS/YoutubeAPI.js"] => { 
				Response::from_file("text/javascript", File::open("src/HTTP/JS/YoutubeAPI.js").unwrap()).with_status_code(200)
			},
			(GET) ["/JS/Variables.js"] => { 
				Response::from_file("text/javascript", File::open("src/HTTP/JS/Variables.js").unwrap()).with_status_code(200)
			},
			// Robots.
			(GET) ["/robots.txt"] => {
				Response::from_file("text/plain", File::open("src/HTTP/robots.txt").unwrap()).with_status_code(200)
			},
			// Oauth.
			(GET) ["/oauth/client-metadata.json"] => {
				Response::from_file("application/json", File::open("src/HTTP/client-metadata.json").unwrap()).with_status_code(200)
			},
			// CSS.
			(GET) ["/CSS/index.css"] => { 
				Response::from_file("text/css", File::open("src/HTTP/CSS/index.css").unwrap()).with_status_code(200)
			},
			(GET) ["/CSS/account.css"] => { 
				Response::from_file("text/css", File::open("src/HTTP/CSS/account.css").unwrap()).with_status_code(200)
			},
			(GET) ["/CSS/expanded.css"] => { 
				Response::from_file("text/css", File::open("src/HTTP/CSS/expanded.css").unwrap()).with_status_code(200)
			},
			(GET) ["/CSS/mail.css"] => { 
				Response::from_file("text/css", File::open("src/HTTP/CSS/mail.css").unwrap()).with_status_code(200)
			},
			(GET) ["/CSS/post.css"] => { 
				Response::from_file("text/css", File::open("src/HTTP/CSS/post.css").unwrap()).with_status_code(200)
			},
			(GET) ["/CSS/setting.css"] => { 
				Response::from_file("text/css", File::open("src/HTTP/CSS/setting.css").unwrap()).with_status_code(200)
			},
			// Actual Web Pages.
			(GET) ["/"] => { 
				Response::from_file("text/html", File::open("src/HTTP/HTML/index.html").unwrap()).with_status_code(200)
			},
			(GET) ["/account"] => { 
				Response::from_file("text/html", File::open("src/HTTP/HTML/account.html").unwrap()).with_status_code(200)
			},
			(GET) ["/expanded"] => { 
				Response::from_file("text/html", File::open("src/HTTP/HTML/expanded.html").unwrap()).with_status_code(200)
			},
			(GET) ["/mail"] => { 
				Response::from_file("text/html", File::open("src/HTTP/HTML/mail.html").unwrap()).with_status_code(200)
			},
			(GET) ["/post"] => { 
				Response::from_file("text/html", File::open("src/HTTP/HTML/post.html").unwrap()).with_status_code(200)
			},
			(GET) ["/setting"] => { 
				Response::from_file("text/html", File::open("src/HTTP/HTML/setting.html").unwrap()).with_status_code(200)
			},
			_ => { 
				Response::from_file("text/html", File::open("src/HTTP/HTML/404.html").unwrap()).with_status_code(404)
			},
		)
	});
}
