Skip to content

furretpaws/hx_webserver

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

hx_webserver

A basic HTTP server library for Haxe (HTTP only)

Installation

Use the package manager haxelib to install hx_webserver.

haxelib install hx_webserver
haxelib git hx_webserver https://github.com/FurretDev/hx_webserver.git

Disclaimer

This library is not meant to be used for production use since it's still in development. (However it's still usable)

Usage

Responding with a simple text

import hx_webserver.HTTPServer;
import hx_webserver.HTTPRequest;

class Main {
    static var Server:HTTPServer;

    static function main() {
        Server = new HTTPServer("0.0.0.0", 80, true/*, false*/);
        Server.onClientConnect = (d:HTTPRequest) -> {
            d.reply("Hello!");
        }
    }
}

Responding with a file

import hx_webserver.HTTPServer;
import hx_webserver.HTTPRequest;

class Main {
    static var Server:HTTPServer;

    static function main() {
        Server = new HTTPServer("0.0.0.0", 80, true/*, false*/);
        Server.onClientConnect = (d:HTTPRequest) -> {
            d.replyWithFile("index.html");
            //NOTE: If the file doesn't exist it won't give an 404 error.
            //You'll have to code that by yourself
        }
    }
}

Responding with the URL file requested Responding with a file

import hx_webserver.HTTPServer;
import hx_webserver.HTTPRequest;

class Main {
    static var Server:HTTPServer;

    static function main() {
        Server = new HTTPServer("0.0.0.0", 80, true/*, false*/);
        Server.onClientConnect = (d:HTTPRequest) -> {
            d.replyWithFile(d.methods[1].substr(1));
            //NOTE: If the file doesn't exist it won't give an 404 error.
            //You'll have to code that by yourself
        }
    }
}

Contributing

Contributions (pull requests) are always welcome, we appreciate every contribution <3

License

MIT

About

A basic HTTP server library for Haxe (HTTP only)

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages