snapdgn / rocket-web-koss

A simple webserver using rocket framework in rust

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Project Title

Koss-Rust-Webserver


A simple webserver using rocket framework in rust.

Demo-Preview

Redacted

Table of contents

Installation

(Back to top)

Rust Installation and Setup


Install rust by "rustup", its simple and blazing fast installation method.Enter this command in your terminal and follow on screen instructions.

curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh



If rustup is already installed in your system simply update it by

rustup update



To check if rust is properly installed in your system run

rustc --version



Please refer to offical docs of rust if you are facing problems in installation. Rust-Installation-Guide

Since this project uses rust nightly , You have to switch over to rust nightly in order for this to work
Note that this step is crucial for this to work
To Switch to Nightly Enter rustup default nightly in your terminal.(recommended)
Or you could also set nigtly-rust on directory basis by rustup override set nightly. I would still recommend the upper one though.

Repo Cloning

After rust installation and setup Clone this repo.

https://github.com/chinsaw/rocket-web-koss.git


A reminder to Switch to nightly again

Usage

(Back to top)

Enter these commands in succesion after cloning the repo

cd rocket-web-koss
cargo run --release

Note:

  • The endpoint is [http://0.0.0.0:8000/static] Make sure to go to the the /static endpoint for the contents to be rendered.
  • Make Sure you type the exact commands
  • Make sure you're in the root directory of the project (this project is not configured to use the relative path) before running cargo run --release, or else page may break since it can't load the css and js which is in another folder.

Development

(Back to top)

I've tried to make this thing as minimalistic as possible with minimum creates, i used only "rocket" version 0.4.10, for this project.

Some neat tricks i Learned:-

  • One could use cargo add <crate name> to easily download and include the crate in Cargo.toml file. You've to download cargo add first by cargo install <crate name>.
  • You could explore a range of crates in crates.io

What i've learned by making this project?

(Back to top)
Frankly, I learned a lot, i didn't know much of the frontend, So in order to render a good html,css,and javascript i had to learn bootstrap a bit and also came to know about template rendering engines in rust such as tera.
Although i never used that in this project, it was a valuable learing experience.
I had to struggle a lot in static file rendering in rust's rocket, as rocket is a relatively new framework and don't have easy-following tutorials.I had to hike around a lot for this, fortunately rust is well documented and that was a big help.

And most importantly i learned docker which was a pleasant and valuable learinig experience.

About

A simple webserver using rocket framework in rust


Languages

Language:HTML 60.5%Language:CSS 28.5%Language:JavaScript 8.3%Language:PHP 1.8%Language:Rust 0.6%Language:Dockerfile 0.3%