Add CGI functionality
This commit is contained in:
parent
ef99f445e0
commit
38bedc8ae7
|
@ -4,6 +4,7 @@ use std::io::prelude::*;
|
|||
use std::io::ErrorKind;
|
||||
use std::net::TcpListener;
|
||||
use std::net::TcpStream;
|
||||
use std::process::Command;
|
||||
|
||||
extern crate argparse;
|
||||
use argparse::{ArgumentParser, StoreTrue, Store};
|
||||
|
@ -78,8 +79,12 @@ fn handle_connection(mut stream: TcpStream, root_dir: String) {
|
|||
let full_path = format!("{}{}", root_dir, _path);
|
||||
let mut exists = Path::new(&format!("{}{}", root_dir, _path).to_string()).exists();
|
||||
if exists {
|
||||
if Path::new(&full_path).is_file(){
|
||||
if Path::new(&full_path).is_file() {
|
||||
_contents = fs::read_to_string(format!("{}{}", root_dir, _path)).unwrap();
|
||||
if _path.contains(".sh") {
|
||||
let command = Command::new(format!("{}", full_path)).output().unwrap();
|
||||
_contents = String::from_utf8(command.stdout).unwrap();
|
||||
}
|
||||
} else {
|
||||
exists = Path::new(&format!("{}{}/index.gmi", root_dir, _path).to_string()).exists();
|
||||
if exists {
|
||||
|
|
Loading…
Reference in New Issue