Giter VIP home page Giter VIP logo

simple-http-server's Introduction

simple-http-server

I get asked, "how can I serve the files I have locally?" A ready answer to this is to use Python's SimpleHTTPServer (now with Python 3, this is http.server). This question, however, is often from individuals who will have Docker installed but don't necessarily want to dig into the details of specific python versions or writing a Dockerfile. The goal of this project is to give a single command with no extra dependencies that will serve the directory you point it at.

WARNING: DO NOT run this in production. This is purely a convenience tool.

Using

To serve files, stand the server up with this docker command. Make sure you map (as a volume with /serve) the directory you wish to serve:

docker run --rm \
    -v <directory-to-serve>:/serve \
    -p 80:8000 \
    jdkelley/simple-http-server:latest

To serve your current directory, use:

docker run --rm \
    -v $(pwd):/serve \
    -p 80:8000 \
    jdkelley/simple-http-server:latest

I find it useful to add a bash function to my profile to avoid typing that all out:

simple-http-server() {
    docker run --rm \
        -v $(pwd):/serve \
        -p 80:8000 \
        jdkelley/simple-http-server:latest
}

And then use it with simple-http-server. You can find an example of the function I use in example/bash_functions.sh.

Building from source

docker build -t http-server:latest .

To run this generated image and serve your current directory, run docker run $(pwd):/serve -p 80:8000 http-server:latest.

Deployed

This is deployed on GitHub Package Registry and Docker Hub.

The source can be found on GitHub.

simple-http-server's People

Contributors

jdkelley avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

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.