I have a small web application done in HTML/JS. I wanted to use a Python Visualization inside in that application.
Executing Python component gives the HTML content, which I want to embedded inside the application.
How could I do this? How to call a Python Script inside JS?
The easiest way to is to a have Python web microframework doing the data/HTML serving for you. Popular framework for just making tiny data-serving applications is Flask.
Here is an example which serves data from Flask and then uses Bokeh visualization framework to do plots out of it.
Bokeh itself has something called "plot server" designed for serving plot graph data, but as I can see this is vertically integrated with Bokeh visulazation library and might not suit for your use case.
Related
I wrote a data processing program in python. My program takes some input data and transforms it using python libraries such as PYTHON-MIP, Numpy, Scipy, Pandas, etc. I want to build a graphical interface for this program and I would like it to be web to display graphs with libraries like Chart JS. I know how to build this app by separating the frontend and the backend. But I would like the processing to run on the client. That is, I want an application without a backend. I don't know what options I have.
The browser (the "client") is not able to run python code. It will have to run on the server side.
With web assembly is possible execute python in the client. The best option is pyodide, that able the numpy, scipy, scikitlearn, pandas, etc. Pyodide
I'm using java spring for backend of my website. I need to add some auto generating graphs to it. But I'm not sure for what I should look for. Should I use a Javascript library or can I do it in java as a backend function? This is my first time using this functionality.
P.S.
I have to deal with a often updating database to fetch data for those graphs.
Check this answer, I would suggest to go with option 2 and use a javascript library like highcharts.
Plot Graph In web application
I've got a question regarding JavaScript charting libraries (Flot Charts, to be more specific).
At the moment, every library I've come across requires an HTML document in order to work (where the chart/graph would be constructed, in a canvas element, for example), but my problem is that I'm not creating a traditional web-page/application that requires an .html document, I'm creating a bot.
The reason I'm using the chart library is to generate an image that the bot can render to the user. In order to generate the graphic, do I need to create some generic html page where I can generate the graphic and then grab it and store it with JavaScript in my NodeJS project? Or perhaps there's something that I'm missing entirely.
Any and all help is really appreciated. Thanks a lot
Since Javascript runs on the client and node runs on the server, you're going to have a hard time getting the server to save a snapshot of your generated graphic. That's typically done on the server side of things.
I would switch your library to Plotly (http://plot.ly) and utilize it's Static Image Export feature:
https://plot.ly/nodejs/static-image-export/
I've made a program in Python 2.7 with a wxWidgets GUI. Now, I want to improve it by making a web GUI, make it multi-platform and port it in Python 3.4. For this purpose, I have to make Javascript and Python communicate (i.e : I want my Python to react on some event on the page and I want my page to react on some Python actions).
I don't really know how to do it, and I don't even know if it's possible.
I've find some libraries, but some are just for Python 2 (pyjamas), and some don't provide what I search, or I don't search enough ^^ (web2py, turbogear, cherrypy).
I would like to find a complete library that ease this communication, and that is rather known and supported, with a compete documentation.
Maybe, there are other ways to do such a web GUI, but I don't find them.
Thanks !
I guess what you want is a single page application.
I would suggest to wrap your python code in a RESTful Api using a python web framework like Flask. This would isolate your python code from the presentation layer.
You could then write the UI in html and javascript and use AJAX to call your python api from javascript.
I am trying to develop a way for Python to build web applications. Using just one HTML file and a python file, the user should be able to develop a small web application. The connection between Python logic/events and HTML can be javascript, and wanted to use something that made life easier than passing a DOM object back and forth.
I found Backbone.js, and thought that this may be something to look into. Any ideas?
I was thinking that Python could create events in javascript structured by Backbone, and then the javascript could talk back and forth with server/client very easily.
Would this work? Or the use of a DOM object with all of the HTML id's and attributes is necessary to use?
Here is how we create the webApp:
At the client side, using HTML5+Javascript and backbonejs
At the server side, using Django and its REST plugin
REST API is used between the client and the server
[Client/HTML5+Javascript + Backbone] ← REST → [Web-Server]—[Django/rest-plugin]
There are a few rest frameworks for Django.
django-rest-framework
tastypieapi
django-piston
Alternative to Django
flask
Also you can see the post in here as well.
Good luck!