Giter VIP home page Giter VIP logo

tcp80x's Introduction

tcp80x

tcp80x is an HTTP server with some pseudo-CGI support.
This is a merger of execfs and tcp80, both written by cinap_lenrek.

Installation:

Install with mk install
Create a /rc/bin/service/tcp80 file:

#!/bin/rc
exec /bin/tcp80x -r /path/to/rules

Request handling:

tcp80x handles request as follows:

  1. Parse the request location
  2. Try to match the location against defined rules
  3. If a rule matches, execute the associated command line (see Rules)
  4. If not, look for a matching file in /usr/web and serve it

NB:

  • Unless -t flag is passed to tcp80x, /usr/web is bound to / before serving static files.
  • For scripts to work properly, they need to return a proper HTTP response.

Rules:

The rules file is used to match incoming requests against a regular expression and if a match is found execute the command associated with the regular expression. The format is:

# Comment
<regex>\t<command line>\n

The command line is transformed with regsub(2) meaning that it can contain references to matches in the regex in the form '\n' where n is a digit.

Example:

First we create a rule file:

/hello/([^'/]+)	/bin/hello '\1'

Then, a hello script:

#!/bin/rc
rfork en
echo 'HTTP/1.1 200'
echo ''
echo 'Hello '^$1

We can now browse to http://server/hello/bob which should be displaying 'Hello bob'.

Credits:

cinap_lenrek:

License:

MIT

tcp80x's People

Contributors

telephil9 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 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.