Giter Club home page Giter Club logo

aphttp's Introduction

apHTTP

apHTTP is an extremely minimalistic and embeddable web server written in Tcl as well as a library for creating custom HTTP servers.

Usage

$ tclsh standalone.tcl <port> <directory containing HTML, CGI and various other content> <map file>

apHTTP itself by default does not serve anything and is meant to be specified with URL maps on which the server must serve the necessary content. This means that if you do have an index.html file in the specified static files folder by visiting localhost on the port on which you’ve specified you will get a 404 Not Found.

The map file that you need to specify must contain at least one URL map. For example, to serve index.html when your server retreives a connection, add this line to your map file, which must have an extension of .map:

/ => index.html

Assuming that you’ll be running the server on port 8000, if the user visits http://localhost:8000 or http://<your IP>:8000/, the index.html file will be presented to the user.

If you have a CGI script that you would like to run, you can create a clean URL for it and add it to the map file, specifying explicitly that the file is executable. For example:

/meower => cgi-bin/generate-meow.tcl CGI

This will mean that if the user visits http://localhost:8000/meower or http://<your IP>:8000/meower, the cgi-bin/generate-meow.tcl script will be executed. Notice that:

  • if the CGI script is not chmodded as executable, the user will get a 500 Internal Server Error

  • if the CGI script exists with a non-zero return code, the user will also get a 500 Internal Server Error

If you want to serve all static content from a specific directory without specifying any clean URLs or URL maps, you can use the all directive and specify the relative path to the folder that you want to serve. For example, I have a folder sounds. If I specify this directive in my map file:

all /sounds

All of the files from the folder sounds can be accessed by the user directly. For example: http://localhost:8000/sounds/meow.wav.

Apart from URL maps, the map file can be filled with mime-type declarations, like this:

# the line below will mean that all files with extension .wav will be server with mime-type audio/wav
wav is audio/wav

Limitations

  • No POST request support, currently. It will be added in a future release, though.

  • No CGI support on Windows. It might not be added in the future, because of problems with environment variables.

  • No documentation for the library part of apHTTP. It will be added soon.

License

OBSD. See LICENSE for more info.

aphttp's People

Contributors

tenfensw 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.