Skip to content

Instantly share code, notes, and snippets.

@nadako
Created March 16, 2015 00:19
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nadako/62ecfba4b6faf14a6c67 to your computer and use it in GitHub Desktop.
Save nadako/62ecfba4b6faf14a6c67 to your computer and use it in GitHub Desktop.
import haxe.Constraints.Function;
@:pythonImport("flask", "Flask")
extern class Flask {
function new(module:String);
function run():Void;
function route<T:Function>(path:String):T->T;
}
class Main {
static function main() {
var app = new Flask(untyped __name__);
app.route("/")(index);
app.run();
}
static function index() {
return "Hello, world!";
}
}
@nadako
Copy link
Author

nadako commented Mar 16, 2015

Generated python code:

from flask import Flask as Flask


class Main:

    @staticmethod
    def main():
        app = Flask(__name__)
        app.route("/")(Main.index)
        app.run()

    @staticmethod
    def index():
        return "Hello, world!"



Main.main()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment