COMMUNITY

Simple setup for basic webapp?

Can you suggest a simple setup to get a basic webapp started that will include a server-side component as well?

(I’d like to explore creating a simple app where a lot of different users could open the page, log in, and presented with a list of items, associate some value with a given item that has not yet been assigned a value by someone else (imagine a pot-luck lunch sign-up sheet). That sort of thing. Some db access/storage required on the server-side.)

In the past I’ve used Python + Bottle.py (tiny, lightweight web framework for Python) for that sort of thing, but no JS. Bottle.py comes with its own dev web server, but one might also use gunicorn behind nginx from what I recall.

Thank you for any guidance.

You can take a look at https://github.com/clemos/try-haxe for a simple web-app with a server-side component. For a quick and easy DB-integration you can use SPOD/haxe-record macros in combination with DB-Admin for automatic schema generation from your classes.

Some tips and tricks can be found here. Note that this post is 5 years old, but the info is still valuable.

Cheers

1 Like

Thanks. The readme there is informative. I see that try-haxe uses the PHP target on the backend, with Apache. Also, looking at its build.hxml file, it looks like it doesn’t require any extra Haxe libraries.

I was going to ask if Haxe has its own http server, analogous to Python’s

python -m http.server 8000

but then I found tink_http. Looks like it can provide a server: http://haxetink.github.io/tink_http/#/getting-started/quick-start

I see another one from the OpenFL project: https://lib.haxe.org/p/http-server/.

It occurs to me that maybe I could use externs, target Python, and use Bottle.py from Haxe.

Or maybe write the skeleton of the webapp in Python, but then implement the app’s libraries in Haxe and compile them to Python.

Would you suggest either of those paths? Or are they both asking for more work than is necessary?

It depends.
The big boon of haxe is that you can leverage the already existing ecosystem and runtime characteristics of a target. php is usually fine when it comes to web-backends, but python & java seem equally fine. I guess you should go with what you feel the most comfortable with and if you experience a lot of friction down the road you can always migrate your haxe-code to another target and regain some perspective.

In any case, take a look around what you need and what is there in terms of functionality and try a few things.

Bonus: Here is a short snippet for a quick test of gunicorn written in haxe. I toyed with this months ago. Sadly I only kept the image, not the actual code :slight_smile:
z312

2 Likes

I have been using coconut, a client-side React.js-like framework but Haxey and type-safe, and tink_web, a type safe RESTful HTTP router (with nodejs server, but support PHP too), for a few apps already.

coconut example: https://github.com/MVCoconut/examples-todomvc/
tink_web example: https://github.com/kevinresol/tink_workshop2017

2 Likes

Thanks, Kevin. Node seems to be the avenue for me to explore.

Aside, I’d be curious to hear if anyone’s using hxcpp or HashLink for a web back-end.

Gotcha. Thanks for the advice, and the cool screenshot, Michael.