The install script has more lines of Bash than the actual main.go source file. Even this README.md file was written in more lines than teenyHTTP.
- Manual overriding of paths
- No dependencies (install helper script requires Bash (unless you compile it yourself))
- Easy port selection
- Ensure you have
Bashinstalled
Note
not needed if not using install helper script
command -v bashcdinto your working directory (replace/your/path/to/your/fileswith your path)
cd /your/path/to/your/files- Run the setup script
curl -fsSL https://raw.githubusercontent.com/supraboy981322/teenyHTTP/main/install-1.sh | shOR
wget -fsSL https://raw.githubusercontent.com/supraboy981322/teenyHTTP/main/install-1.sh | sh- Follow the on-screen instructions
- Create a systemd service file
(you may need
supermissions, replacenvimwith your prefered text editor, such asnano[nanois easier thannvim])
nvim /etc/systemd/system/teenyHTTP.service- Enter the following
(replace
/your/working/directory/with the directory of your configuration JSON files and files to serve, and/your/executable/pathwith the directory to the teenyHTTP executable)
Important
It is highly advised to use a user and group other than root for security purposes.
(if you do, make sure the selected user and group have access to the teenyHTTP server and files)
[Unit]
Description=the teenyHTTP web server
After=syslog.target network.target
[Service]
User=root
Group=root
Type=simple
WorkingDirectory=/your/working/directory/
ExecStart/your/executable/path/teenyHTTP
TimeoutStopSec=20
KillMode=process
Restart=always
[Install]
WantedBy=multi-user.target
- Enable and start the service (you may need
supermissions)
systemctl enable teenyHTTP.servicethen
systemctl start teenyHTTP.service- Make sure the service was started (you may need
supermissions)
systemctl status teenyHTTP.service-
-
Open your
settings.jsonfile (replace/your/working/dirwith the path to your working directory, andnvimwith your prefered text editor)nvim /your/working/dir/settings.json
-
Edit the line that has
"port":(replace1234with the port you want teenyHTTP to use)"port": "1234",
-
-
-
Open your
settings.jsonfile (replace/your/working/dirwith the path to your working directory, andnvimwith your prefered text editor)nvim /your/working/dir/settings.json
-
Edit the line that has
"override":(replace1234with the port you want teenyHTTP to use) valid options are:trueandfalse(no quotations)"override": false,
-
-
-
Open your
override.jsonfile (replace/your/working/dirwith the path to your working directory, andnvimwith your prefered text editor)nvim /your/working/dir/override.json
-
Create a new line in the following format after the openning brace (
{)"your-url/path": "your_file/path.html",
your
override.jsonfile should look similar to this:{ "your-url/path": "your_file/path.html", "", "index.html" }
-
Warning
Ensure that you do not have a comma at the end of the last line before the ending brace