• Stars
    star
    371
  • Rank 115,103 (Top 3 %)
  • Language
    Rust
  • Created almost 9 years ago
  • Updated 12 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A simple static HTTP server in Rust, for learning and local doc development

basic-http-server

A simple static HTTP server, for learning and local development.

basic-http-server is designed for two purposes:

  • as a teaching tool. It is a simple and well-commented example of basic tokio, hyper, and asynchronous Rust programming, with async / await.

  • for local development. It serves static HTML content, and with the -x flag, provides convenience features useful for creating developer documentation, including markdown rendering and directory listing.

The entire reference source for setting up a hyper HTTP server is contained in main.rs. The ext.rs file contains developer extensions.

Developer extensions

When passed the -x flag, basic-http-server enables additional conveniences useful for developing documentation locally. Those extensions are:

  • Rendering files with the ".md" extension as Markdown.

  • Listing directories when no "index.html" file is found.

  • Serving common source code files as "text/plain" so they are rendered in the browser.

This makes basic-http-server useful for the following scenarios:

  • Previewing markdown content. Draft your README.md changes and view them locally before pushing to GitHub.

  • Navigating to local documentation, including Rust API documentation. Just run basic-http-server -x in your project directory, and use the directory listing to navigate to target/doc, then find the crates to read from there (cargo doc doesn't put an index.html file in target/doc).

Installation and Use

Note that basic-http-server is not production-ready and should not be exposed to the internet. It is a learning and development tool.

Install with cargo install:

$ cargo install basic-http-server
$ basic-http-server

To turn on the developer extensions, pass -x:

$ basic-http-server -x

To increase logging verbosity use RUST_LOG:

RUST_LOG=basic_http_server=trace basic-http-server -x

Command line arguments:

USAGE:
        basic-http-server [FLAGS] [OPTIONS] [ARGS]

FLAGS:
    -x               Enable developer extensions
    -h, --help       Prints help information
    -V, --version    Prints version information

OPTIONS:
    -a, --addr <ADDR>    Sets the IP:PORT combination (default "127.0.0.1:4000")

ARGS:
    ROOT    Sets the root directory (default ".")

License

MIT/Apache-2.0

More Repositories

1

rust-anthology

Learn Rust from the best
Shell
1,353
star
2

multirust

[DEPRECATED] A tool for managing multiple Rust installations
Shell
656
star
3

my-rust-lists

Lightly organized personal notes about Rust
445
star
4

httptest

An example of a Rust web service with Iron and Hyper
Rust
326
star
5

rust-sdl

SDL bindings for Rust
Rust
179
star
6

annotated-std-rs

An annotation of the Rust standard library
71
star
7

home

Canonical definitions of home_dir, CARGO_HOME, and RUSTUP_HOME
Rust
65
star
8

wasm-opt-rs

Rust bindings for Binaryen's wasm-opt
WebAssembly
63
star
9

cargo-crusader

Test the downstream impact of Rust crate changes before publishing
Rust
59
star
10

treasuretree

A real-world treasure hunt game where the treasures are represented as QR codes in the physical world, and NFTs in the virtual.
Rust
51
star
11

ferris-fencing

Rust
42
star
12

rustle

Install a Cargo application from source without a preexisting Rust installation
Shell
37
star
13

rust-in-china

JavaScript
36
star
14

the-end-of-unsafety

https://brson.github.io/the-end-of-unsafety
JavaScript
33
star
15

rust-chamber

Rust as sandbox
Rust
32
star
16

burst

Realtime programming for Rust
Rust
27
star
17

temple-of-rust

Tutum. Simul. Celerem.
CSS
23
star
18

archaea

Historic Rust code browsing
JavaScript
22
star
19

rustray

Sebastian Sylvan's Rust ray-tracer
Rust
20
star
20

big_s

Rust's missing `String` literal
Rust
19
star
21

being-rust

Intro to Rust talk
JavaScript
15
star
22

rubyrustdemo

JavaScript
14
star
23

brson.github.com

JavaScript
11
star
24

paxos-for-dummies-like-me

Rust
11
star
25

beast

Go
10
star
26

rust-is-for-blockchain

Slides about the Rust in the blockchain industry
JavaScript
10
star
27

stabworld

Tools for analyzing how the Rust ecosystem is using the language
Shell
10
star
28

zenburn-konsole

Zenburn for Konsole
8
star
29

contract-game

Rust
8
star
30

rust-infra

Information about Rust infrastructure
8
star
31

og_fmt

Will the real `format!` please stand up?
Rust
7
star
32

hackmd-collab

7
star
33

megamalloc

Rust
6
star
34

rust-sha2

SHA-2 in pure Rust
Rust
6
star
35

cargo-bake

Smarter default optimization settings for Rust + Cargo
Rust
6
star
36

blocksy3

An in-process key value store.
Rust
6
star
37

ctrs

A Rust language conformance test suite
Rust
5
star
38

cargo-lock-to-dot

Generate a GraphViz DOT file from a Rust Cargo.lock file
Python
5
star
39

pwrabs

Rust
5
star
40

ragel-dist

ragel repo used by servo
C++
5
star
41

fireflowers

HTML
5
star
42

bloop

Rust
4
star
43

synth2

Rust
4
star
44

heka-rs

Originally https://bitbucket.org/trink/heka_rs
Rust
4
star
45

rust-contract-comparison

JavaScript
3
star
46

rust-llvm

LLVM bindings for Rust
Rust
3
star
47

slush

C#
3
star
48

rust-dev-archives

Archives of the rust-dev mailing list
3
star
49

worklog-scan

Rust
3
star
50

soroban-token-fuzzer

Rust
3
star
51

cargobomb-reports

2
star
52

project-servo-talk

Backup of Graydon's original Servo talk
2
star
53

devscripts

Scripts for configuring my dev environment
Shell
2
star
54

rust-irc-logs

Historic Rust IRC logs
2
star
55

fancy_flocks

Rust
2
star
56

quickshake

Shrinks Java libraries fast
Scala
2
star
57

solana-move-demo

Move
2
star
58

mem-basics

Rust
2
star
59

blocksy2

Rust
1
star
60

tryrust

JavaScript
1
star
61

rust-art

1
star
62

blip

C
1
star
63

rust-hello

Hello World in rust.
Rust
1
star
64

wamalama

Rust
1
star
65

atomic_blobject

Rust
1
star
66

load-maker

Load up your CPUs
Rust
1
star
67

rustzlib

zlib bindings for rust
Rust
1
star
68

parse_list

Parse files and lists of stringified things into lists of thingified things
Rust
1
star
69

rusty-cairo

Cairo bindings for Rust, enabling a powerful interface to vector graphics.
Rust
1
star
70

dochub

JavaScript
1
star
71

beagle-delicious

C#
1
star
72

bench-cargo-profiles

Rust
1
star
73

rustscripten

Tools for building Rust code with emscripten
JavaScript
1
star
74

wasm-encrypted-pastebin

1
star
75

stoptime

Scala
1
star
76

slide-deck-template

JavaScript
1
star
77

result_iter

Rust
1
star
78

servo-pages

Hosted servo test cases
JavaScript
1
star
79

harfbuzz-servo

C++
1
star
80

euler

Haskell
1
star
81

instant-httpd

A simple script to serve static web pages from the current directory with no configuration
Python
1
star
82

coconuts

Jupyter Notebook
1
star
83

rustpcre

PCRE bindings for Rust
Rust
1
star
84

blocksy

Rust
1
star
85

rwh

Haskell
1
star
86

ckb-vm-rs-tests

Rust
1
star
87

memstuff

Rust
1
star
88

servo-buildbot

1
star
89

cargo-index-tool

Rust
1
star
90

ckb-rpc-test

Rust
1
star
91

gyp

Clone of gyp for Rust
Python
1
star
92

rust_glfw

glfw bindings for the rust programming language
Rust
1
star
93

audiotool

Rust
1
star
94

slq

Rust
1
star