Skip to content

59naga/difficult-http-server

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

51 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DifficultHttpServer NPM version Build Status Coverage Status

Instant HTTP Server for Single Page Application

Usage

npm install difficult-http-server --global

# create empty project
mkdir my-project
cd my-project

# create empty files(requirement)
dhs touch
tree .
# my-project
# ├── index.coffee
# ├── index.jade
# └── index.styl

# fetch packages(optional)
npm install bower --global
bower init # or `echo '{"name":"'$(basename $PWD)'"}' > bower.json`
bower install angular-ui-router --save

# boot
dhs . --open
# DifficultHTTPServer at http://localhost:59798 using .

index.jade

doctype html
html
  head
    meta(charset="UTF-8")
    title DifficultHTTPServer
    script(src="pkgs.js")
    script(src="index.js")
    link(href="index.css" rel="stylesheet")
  body
    h1 hello dhs

Other options

See also $ dhs

Routes

GET /

parse /index.jade

GET /index.js

parse /index.coffee using coffee-reactify with ng-annotate + plain-jadeify + brfs

GET /index.css

parse /index.styl with kouto-swiss

GET /pkgs.js / GET /pkgs.min.js

combine dependencies of /bower.json using express-onefile

Otherwise

to static serving. (If a static file exists, the middlewares will not be executed)

Getting started

React

mkdir gs-react
cd gs-react

dhs touch
touch bower.json
tree . -L 1
# .
# ├── bower.json
# ├── index.coffee
# ├── index.jade
# └── index.styl

bower.json

{
  "name": "gs-react",
  "dependencies": {
    "react": "~0.14.0"
  },
  "overrides": {
    "react": {
      "main": [
        "react.js",
        "react-dom.js"
      ]
    }
  }
}

index.coffee

class Hello extends React.Component
  constructor: ->
    super

    @state= {message:'this is react'}

  render: ->
    <div onClick={@handleClick}>
      <p>{@state.message}</p>
    </div>

  handleClick: =>
    @setState {message:'awesome'}
  
addEventListener 'DOMContentLoaded',->
  ReactDOM.render <Hello />,document.querySelector 'main'

index.jade

doctype html
html
  head
    meta(charset="UTF-8")
    title DifficultHTTPServer
    script(src="pkgs.js")
    script(src="index.js")
    link(href="index.css" rel="stylesheet")
  body
    main

index.styl

// unused
bower install

dhs . --open
# DifficultHTTPServer at http://localhost:59798 using .

Example

Awesome converters

See also

License

MIT

About

(Experimental fragile project, Please use webpack.) Instant HTTP Server for Single Page Application

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published