From: Waldemar Kozaczuk <jwkozac...@gmail.com>
Committer: Waldemar Kozaczuk <jwkozac...@gmail.com>
Branch: master

add simple flask example

Signed-off-by: Waldemar Kozaczuk <jwkozac...@gmail.com>

---
diff --git a/flask-example/GET b/flask-example/GET
--- a/flask-example/GET
+++ b/flask-example/GET
@@ -0,0 +1,24 @@
+#!/usr/bin/env bash
+set -e
+
+MODULE_DIR=$(readlink -f .)
+
+rm -rf upstream
+
+mkdir upstream
+pushd upstream
+git clone --depth 1 https://github.com/auth0-blog/flask-restful-apis.git
+
+cd flask-restful-apis
+git apply ../../app.patch
+
+mkdir site-packages
+pip3 install --no-cache-dir --target ./site-packages flask marshmallow
+
+popd
+
+PYTHON_VERSION=$(python3 -c 'import sys; print("%s.%s" % 
(sys.version_info.major,sys.version_info.minor))')
+
+echo "/lib/python${PYTHON_VERSION}/site-packages/**: 
${MODULE_DIR}/upstream/flask-restful-apis/site-packages/**" > usr.manifest
+echo "/lib/python${PYTHON_VERSION}/dist-packages: ->site-packages" >> 
usr.manifest
+echo '/cashman/**: ${MODULE_DIR}/upstream/flask-restful-apis/cashman/**' >> 
usr.manifest
diff --git a/flask-example/Makefile b/flask-example/Makefile
--- a/flask-example/Makefile
+++ b/flask-example/Makefile
@@ -0,0 +1,8 @@
+.PHONY: module
+module: upstream/flask-restful-apis/cashman
+
+upstream/flask-restful-apis/cashman:
+       ./GET
+
+clean:
+       rm -rf ./upstream usr.manifest
diff --git a/flask-example/app.patch b/flask-example/app.patch
--- a/flask-example/app.patch
+++ b/flask-example/app.patch
@@ -0,0 +1,10 @@
+diff --git a/cashman/index.py b/cashman/index.py
+index 7868b9f..6e9b1a8 100644
+--- a/cashman/index.py
++++ b/cashman/index.py
+@@ -47,4 +47,4 @@ def add_expense():
+ 
+ 
+ if __name__ == "__main__":
+-    app.run()
++    app.run(host="0.0.0.0")
diff --git a/flask-example/module.py b/flask-example/module.py
--- a/flask-example/module.py
+++ b/flask-example/module.py
@@ -0,0 +1,6 @@
+from osv.modules import api
+
+#For a proper interactive python terminal
+api.require('unknown-term')
+
+default = api.run(cmdline="--env=TERM=unknown --env=PYTHONPATH=/ 
--env=PYTHONHOME=/ --env=PYTHONPLATLIBDIR=lib /python /cashman/index.py")

-- 
You received this message because you are subscribed to the Google Groups "OSv 
Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to osv-dev+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/osv-dev/000000000000ee31ea05ece30fcf%40google.com.

Reply via email to