GithubHelp home page GithubHelp logo

robertohuertasm / microserver Goto Github PK

View Code? Open in Web Editor NEW
54.0 3.0 11.0 131 KB

๐Ÿ”ฌ Simple ad-hoc server with SPA support based on Warp.

Home Page: https://crates.io/crates/microserver

License: MIT License

Rust 77.22% HTML 8.09% Dockerfile 14.69%
server localserver rust rust-crate http-server spa single-page-app warp spa-support microserver

microserver's Introduction

microserver

Actions Status Crates.io Docker Build Docker Pulls

Simple ad-hoc server with SPA support based on Warp! Excellent for testing React, Angular, Vue apps and the like.

Installation

You can compile it yourself:

cargo install microserver

or you can download the executable from Github releases and add it to your path.

Usage

No argument is mandatory so the current folder will be used as default if no path is specified

microserver

you can, of course, set the path of the folder you want to be served, by default in port 9090.

microserver ./path/to/folder

Need help?

microserver -h

Changing the address

# by default microserver will use 0.0.0.0
microserver -a 127.0.0.1

Changing the port

# by default microserver will use 9090 port
microserver -p 3000

SPA support

SPA support is enabled by default, meaning that if a resource is not found traffic will always be redirected to index.html.

If you want to opt-out of this behavior just use the --no-spa flag.

In the case you ever need to change the default spa index you can provide the --spa-index flag.

Docker

There are several ways to use microserver with a Docker image:

With a Dockerfile like the following:

# please omit the version if you just want the latest
FROM robertohuertasm/microserver:v0.1.6
# public being the location of your app files
COPY public/ /app/

You can then run your SPA / static site using:

$ docker build -t my-service:local .
$ docker run -p 9090:9090 my-service:local
MicroServer running on port 9090!
Serving /app
Spa support: true. Root: index.html

Alternatively, you could mount a volume with your content:

docker run -p 9090:9090 -v $(pwd)/public:/app robertohuertasm/microserver:v0.1.6

More complex Dockerfile usage example with a multi-stage build of a React SPA:

FROM node:10.18-stretch-slim as builder
WORKDIR /app
COPY ./ /app
RUN yarn
RUN yarn build

FROM robertohuertasm/microserver:v0.1.6
COPY --from=builder /app/public /app/

If you don't want the default arguments

In this case whenever you run the microserver image, you'll have to be explicit about the arguments:

# don't forget to add "/app" as your final argument
docker run -p 9090:9090 -v $(pwd)/public:/app robertohuertasm/microserver:v0.1.6 "/microserver" "--no-spa" "/app"

microserver's People

Contributors

flosse avatar nessex avatar robertohuertasm avatar tshepang avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

microserver's Issues

Unable to serve WOFF2 files?

While this works fine in Chromium, on Firefox I get:

downloadable font: rejected by sanitizer

when attempting to serve .woff2 files. Any ideas why this might be happening?

feature request: bind to specific address

Currently, only binding to all IPv4 interfaces (0.0.0.0) is supported. I would like to have the option to bind to only a specific address, perhaps via a --bind command line argument.

This would allow for:

  • Only binding to the loopback interface (--bind 127.0.0.1)
  • IPv6 support (--bind [::])

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.