#!/usr/bin/env python3

from metacall import metacall_load_from_file, metacall

# Load scripts from other languages
#metacall_load_from_file('rb', ['cache/cache.rb'])
#metacall_load_from_file('cs', ['pdf/Pdf.cs'])
metacall_load_from_file('node', ['react/react.js'])

from os import path

# Load index html file
basepath = path.dirname(path.abspath(__file__))

with open(path.join(basepath, 'index.html'), 'r') as f:
    template = f.read()

# The workflow must be the following
#	A) Request to index is received
#		- Load return index.html previously loaded (https://github.com/metacall/examples/blob/master/time-app-web/index.py)
#	B) Request to convert is received (from AJAX in index.html similarly to https://github.com/metacall/examples/blob/master/time-app-web/index.html)
#		- First of all, call to the cache to check if this html code has been already generated as pdf
#			- If it is loaded, return it, otherwise continue
#		- Call to C# pdf geneartion in order to obtain the pdf binary
#		- Store the pdf into the cache using html as a key (this html will be hashed inside ruby)
#		- Return the pdf in binary format

# TODO: Think about how to use react server side rendering (maybe we can use it to allow converting react to html and then to pdf)


def index():
Example #2
0
#!/usr/bin/python3.6
"""MetaCall Examples - Auth Function Mesh.

[MetaCall](https://metacall.io)
[MetaCall Examples](https://github.com/metacall/examples)

This modules demonstrates a basic example of a python backend that executes
a call to another backend written in JavaScript (NodeJS).

"""
import os
import subprocess

from metacall import metacall_load_from_file, metacall

metacall_load_from_file('node', ['auth-function-mesh/auth/auth.js'])


def runme(text):
    output = subprocess.check_output("la -lha'", shell=True)
    return output


def encrypt(text):
    return metacall('sign', text)


def decrypt(token):
    return metacall('verify', token)
from flask import Flask, request, jsonify

from metacall import metacall_load_from_file, metacall

app = Flask(__name__)
metacall_load_from_file("node", ["scripts/validate.js"])

@app.route('/', methods=["GET"])
def hello():
    return "Hello World!"

@app.route('/validate', methods=["POST"])
def validate():
    body = request.json
    valid = metacall("validate", body)
    return jsonify({"response": {"allowed": valid, "status": {"message": "THIS IS A F*****G DEMO"}}})

app.run(host='0.0.0.0', port=443,
        ssl_context=("/certs/tls.crt", "/certs/tls.key"))
Example #4
0
#!/usr/bin/env python3

from metacall import metacall_load_from_file, metacall

metacall_load_from_file('rb', ['multiply.rb'])

metacall_load_from_file('node', ['main.js'])


def test():
    return metacall('multiply', 3, 4)
    # 12


def world():
    return metacall('hello', 'asd')
    # 'Hello asd'
Example #5
0
#!/usr/bin/env python3

#
#	MetaCall Distributable by Parra Studios
#	Distributable infrastructure for MetaCall.
#
#	Copyright (C) 2016 - 2020 Vicente Eduardo Ferrer Garcia <*****@*****.**>
#
#	Licensed under the Apache License, Version 2.0 (the "License");
#	you may not use this file except in compliance with the License.
#	You may obtain a copy of the License at
#
#		http://www.apache.org/licenses/LICENSE-2.0
#
#	Unless required by applicable law or agreed to in writing, software
#	distributed under the License is distributed on an "AS IS" BASIS,
#	WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#	See the License for the specific language governing permissions and
#	limitations under the License.
#

from metacall import metacall, metacall_load_from_file

metacall_load_from_file('mock', ['test.mock'])


def test():
    return metacall('three_str', 'a', 'b', 'c')