[go: up one dir, main page]

hx_webserver

A basic HTTP server library for Haxe (HTTP only)
https://github.com/FurretDev/hx_webserver

To install, run:

haxelib install hx_webserver 0.0.3 

See using Haxelib in Haxelib documentation for more information.

README.md

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

Contributors
Furret
Version
0.0.3
Published
2 years ago
License
MIT

All libraries are free

Every month, more than a thousand developers use Haxelib to find, share, and reuse code — and assemble it in powerful new ways. Enjoy Haxe; It is great!

Explore Haxe

Haxe Manual

Haxe Code Cookbook

Haxe API documentation

You can try Haxe in the browser! try.haxe.org

Join us on GitHub!

Haxe is being developed on GitHub. Feel free to contribute or report issues to our projects.

Haxe on GitHub