kore

An easy to use, scalable and secure web application framework for writing web APIs in C.
Commits | Files | Refs | README | LICENSE | git clone https://git.kore.io/kore.git

commit a27227d37f447b1a2a2f948ef4aaa89ffac030be
parent b6cb6c14f2e0f933fb0bff644bc70e2e57c8cb37
Author: Joris Vink <joris@coders.se>
Date:   Mon, 19 Apr 2021 09:47:18 +0200

Rework how kodev create does python apps.

Drop the kore.conf for python apps, all configuration
can be done from inside the python code since kore4.

Adds all the basic goo in the app.py file to get up and running.

Diffstat:
src/cli.c | 53++++++++++++++---------------------------------------
1 file changed, 14 insertions(+), 39 deletions(-)

diff --git a/src/cli.c b/src/cli.c @@ -209,7 +209,6 @@ static void file_create_src(void); static void file_create_config(void); static void file_create_gitignore(void); static void file_create_python_src(void); -static void file_create_python_config(void); static void cli_generate_certs(void); static void cli_file_create(const char *, const char *, size_t); @@ -253,7 +252,6 @@ static const char *python_gen_dirs[] = { static struct filegen python_gen_files[] = { { file_create_python_src }, - { file_create_python_config }, { file_create_gitignore }, { NULL } }; @@ -336,41 +334,33 @@ static const char *build_data = "# included if you build with the \"prod\" flavor.\n" "#}\n"; -static const char *python_config_data = - "# %s configuration\n" - "\n" - "server tls {\n" - "\tbind 127.0.0.1 8888\n" - "}\n" - "tls_dhparam\tdh2048.pem\n" - "\n" - "domain * {\n" - "\tattach\t\ttls\n" - "\n" - "\tcertfile\tcert/server.pem\n" - "\tcertkey\t\tcert/key.pem\n" - "\n" - "\troute\t/\tkoreapp.index\n" - "}\n"; - static const char *python_init_data = "from .app import koreapp\n"; static const char *python_app_data = "import kore\n" "\n" - "class App:\n" + "class KoreApp:\n" " def __init__(self):\n" " pass\n" "\n" " def configure(self, args):\n" - " kore.config.file = \"kore.conf\"\n" + " kore.config.tls_dhparam = \"dh2048.pem\"\n" " kore.config.deployment = \"development\"\n" + " kore.server(\"default\", ip=\"127.0.0.1\", port=\"8888\")\n" + "\n" + " d = kore.domain(\"*\",\n" + " attach=\"default\",\n" + " key=\"cert/key.pem\",\n" + " cert=\"cert/server.pem\",\n" + " )\n" + "\n" + " d.route(\"/\", self.index, methods=[\"get\"])\n" "\n" " async def index(self, req):\n" " req.response(200, b'')\n" "\n" - "koreapp = App()"; + "koreapp = KoreApp()"; static const char *dh2048_data = "-----BEGIN DH PARAMETERS-----\n" @@ -876,19 +866,6 @@ file_create_python_src(void) } static void -file_create_python_config(void) -{ - int l; - char *name, *data; - - (void)cli_vasprintf(&name, "%s/kore.conf", appl); - l = cli_vasprintf(&data, python_config_data, appl); - cli_file_create(name, data, l); - free(name); - free(data); -} - -static void file_create_src(void) { char *name; @@ -1616,10 +1593,8 @@ cli_run_kore_python(void) fatal("could not get cwd: %s", errno_s); args[0] = cmd; - args[1] = "-frnc"; - args[2] = "kore.conf"; - args[3] = pwd; - args[4] = NULL; + args[1] = pwd; + args[2] = NULL; execvp(args[0], args); fatal("failed to start '%s': %s", args[0], errno_s);