Ejemplo llamada a .py (python) - Forum

Forum Navigation
You need to log in to create posts and topics.

Ejemplo llamada a .py (python)

Hola a todos,

Hi,

  • Alguien ha hecho alguna aplicacion desde VNW llamando a modulos python que me pueda compartir un ejemplo por favor ??
  • Someone have some example about execute pyhon modules inside VNW to share please ??

Saludos y gracias,

Regards,

Sam

Hola @lesanch,

He subido este sencillo script en Python 3 a CloudNEO:

#!/usr/bin/python

import cgi, cgitb 

print ("Access-Control-Allow-Origin: *\r\n\r\n")

# Create instance of FieldStorage 
form = cgi.FieldStorage() 

# Get data from fields
firstName = form.getvalue('firstName')
lastName  = form.getvalue('lastName')
age  = form.getvalue('age')
gender  = form.getvalue('gender')

print ("Response from Python script:<br><br>")

if firstName:
  print ("First name: "+firstName+" <br>")
  
if lastName:
  print ("Last name: "+lastName+" <br>")
  
if age:
  print ("Age: "+age+" <br>")
  
if gender:
  print ("Gender: "+gender+" <br>")

Para probarlo  abre la App the ejemplo "FormSubmit" y en la propiedad "action" del formulario "Form1" cambia la dirección que aparece por esta otra: https://sinlios.xyz/python/pythontest.py

Es mi primer script en python :)

Saludos!

Vadim has reacted to this post.
Vadim

Hola @LuisHP,

Muchas gracias por la info y el ejemplo, voy a tratar de probarlo y te dejo saber.

Igualmente estuve buscando algunas cosas y encontré algo interesante para realizar llamadas a python desde javascript, es una librería llamada Brython: https://brython.info/index.html que estaría muy bueno investigar para realizar un plugin con ese producto para VNWweb. Yo no se Javascript por lo cual me sería medio difícil interntarlo pero quizás alguien pueda crearlo si le llama la atención.

Según investigué Python puede llamarse combinando entre otros usando Jquery  / Django / Jason pero la curva de aprendizaje es medio alta para alguien que recien empieza en esto de la web. También está Flask que es más lite y de aprendizaje un poco mas rápido. También vi la opción que planteas del uso de llamadas CGI pero según comentan es mucho menos recomendado en cuanto a seguridad se refiere.

Pero bueno dejo acá la opción de Brython que quizás los mas avezados algún día puedan intentar algo para simplificar el uso con un plugin en VNWeb para los no programadores de base como algunos de nosotros.

 

Saludos y gracias,

Sam

@luishp

This looks very promising ... did not know that Python scripts can be hosted/run on websites like those offered by neoCloud (any special requirements for neoCloud clients to be able to do this ?)

W3schools ... https://www.w3schools.com/python/default.asp ... provides a lot of help to those wanting to learn this scripting language and all it can do, including ...

- read/write text files (including JSON content)
- access mySQL and mongoDB databases

I see else where that you can also send email using Python scripts ... if true/simple, then it would make VisualNEOWeb a complete solution for Business Apps.

Wonder if it could be the recipient of a CGI based solution you offered recently.

P.S. I tried this ... https://sinlios.xyz/python/pythontest.py?firstName=qwerty ... from the address box of my Chrome Browser ... and got this result ...

Response from Python script:<br><br>
First name: qwerty <br>

... lots of promise !!! ... even for Apps made with VisualNEOWin (InternetGet/InternetPost and via WebBrowser object)

 

Thanks @lesanch for querying about the use of Python with VisualNEOWeb.

Hi @Gaev,

if you know some Javascript and want to implement python call's please also take a look to this as i mentioned before:  https://brython.info/index.html

A Python 3 implementation for client-side web programming

Without a doubt, you've seen a clock like this in demos of HTML5However, right click and view the source of this page...
It is not Javascript code! Instead, you will find Python code in a script of type "text/python".
Brython is designed to replace Javascript as the scripting language for the Web. As such, it is a Python 3 implementation (you can take it for a test drive through a web console), adapted to the HTML5 environment, that is to say with an interface to the DOM objects and events.
Speed of execution is similar to CPython for most operations.
The gallery highlights a few of the possibilities, from creating simple document elements to drag and drop and 3D navigation. A wiki lists some applications using Brython.
You can also take a look at presentations made in various conferences.

Regards,

Sam

@gaev I have added information about how to use Python scripting language in CloudNEO here.
Regards.

@luishp

Hola Luis, te comento que probé lo que enviaste y funciona de maravillas, así que voy a comenzar a testar con aplicaciones mas avanzadas en python y cualquier duda te dejo saber, mi objetivo es conectarme a bbdd Oracle para realizar diferentes tareas, y quizás junto a @Gaev se pueda sacar un plugin que facilite los trabajos.

Mil gracias.

Saludos,

Sam

luishp has reacted to this post.
luishp

Hola @Luishp,

Te comento que recien terminé unas pruebas y pude conectarme perfectamente y realizar operaciones contra bbdd Oracle a través de python usando como base el ejemplo de Form Submit. Con el tiempo voy a intentar crear un plugin usando modulos python por si alguien más necesitara hacer lo mismo contra bbdd Oracle en el que se puedan realizar diversas tareas (insert,delete,update, abm de usuarios, etc...) cada tarea estaría separada por un módulo de python escpecíficamente creado para ello.

Saludos,

Sam

@lesanch genial! suena muy prometedor!