I know this is kind of weird and not secure at all, but is there a way of displaying a bash shell with a remote control on the machine where the webapp is running ?
I would like to have a bash interpreter running directly in the webapplication in flask, does anyone knows how to do such a thing ?
Thanks a lot,
If my post wasn't clear enough just tell me and I will try to improve it.
You can create an interface that looks like you opened a new terminal. To do so, create a form, and everytime you hit Enter, you send this data (using jQuery.ajax for instance) to the server.
On the server side, use subprocess to run the commands you get from the server. You might need to parse this data (something like: my_string.split(' ')) in order to get the argument in a list. You can return the result of that command using: subprocess.check_output in a JSON data type to the client. With Javascript (and jQuery) you can now parse that data and display it wherever you want.
Related
I've gotten a task at University to create a website for teaching other students how to use python libraries (Scrapy, BS) for web scraping. I've already set up the frontend part with React and React Ace editor and now I'm trying to figure out how pass code that user entered to the script. Do I need to make my own server (api) or I can call the python script directly and pass all the code using ajax request?
What is the best approach?
What I want is to pass all the code that user entered in the online editor to the python script and then return the output of that script as a response to the initial request, so that I could check whether the result is correct.
my suggestion is to create a server with API (it's actually AJAX)
and then to run the Python code,
one good option us to create express app (Node.js HTTP server) and use python-shell see the first example with runString option.
you will need a server with node.js and python installed.
of course this only for a university task, in this option you run the code on your server, and it's a pretty big security issue.
I'm kind of new to node.js and Javascript so forgive me if the question is poorly worded.
I'm using cheeriojs to scrape data from a site. I'm running the js file that scrapes the data in the command line and it outputs the data I want, but I want to be able to have access to this data on a webpage, where I can put it into a table. (or anything else I want for that matter). How exactly do I do this?
Thank you
Learn how to use express.
Serve the page to a browser, by reading the file and serving it with an express endpoint, or to curl or something. ie curl localhost:8080/your-endpoint
Using the browser manipulate the page inside of the browsers dev tools.
Figure out how to get the current DOM as an html string.
Figure out how to use the fetch API inside of a browser such as fetch(url, {method: 'POST'}).then(...)
After manipulating the DOM with the browsers dev tools.
POST the results back to express on the nodejs server.
Save the req.body or req.data or req.params to a file.
Side notes:
- figure out what a callback is, figure out how promises work
- do some research on express middleware
- look into setInterval, setTimeout
Related:
Node.js quick file server (static files over HTTP)
How do I get HTML corresponding to current DOM tree?
fetch(), how do you make a non-cached request?
What is Express.js?
https://github.com/Concatapult/node-catapult/blob/master/server/index.js
Writing files in Node.js
Other options, use a text editor, use sed, grep, awk, bash, or something else that doesn't require serving files to a browser?
I'm building a Meteor application that needs to receive JMS or AMQP messages, process them, and store the results in Meteor's MongoDB. I want this all to happen on the server, not the client.
I read the ActiveMQ AJAX page and that seems like a promising lead, but I don't know how to get it working. I was hoping to just create a new .js file in my project's server folder and put all the code in there, but creating the ActiveMQ AJAX servlet and importing the ActiveMQ javascript files seems to require HTML tags. Also, does AciveMQ need to be running for the servlet to work?
I'm new to web development.
You should take a look at node-amqp (https://www.npmjs.com/package/amqp). It should slip nicely into a meteor project and give you the functionality you are looking for. Once you install it and require it, you should be able to connect to your message server, create a queue, receive messages into the queue, and then it's just up to you to process them and store them to your mongo.
I have a site built in Javascript/PHP.
I have a terminal server that I can connect to using puTTy.
What I would like is to display the terminal server on the website.
I want to be able to send data to the terminal server through the code and display the response in the terminal screen.
I am not sure what could help me accomplish this. Are there any Javascript, PHP, Python plugins for this type of thing? I was able to play around with one PHP plugin but it only allowed me to send a command and get a response back. I would like to be able to actually see the terminal session as I would in puTTy.
You can use a Java applet for this.
http://weavervsworld.com/ssh/ssh.php
I am new in JavaScript, and now I want to run a Linux application in JavaScript and show the result in a web page. It all happens in client without a server. But for security issues or something else, JavaScript as no such interfaces. I know in Windows, it could be achieved with activeX, but how could I achieve this in Linux?
I just wanna make js+browser equal to a client application without the complex GUI design. So there is no server. Any easy way to accomplish it?
Maybe Node-webkit is what you want.
It allows you to easily create a desktop application in javascript and access "low-level" stuff so you can run commands, without the need of an http server.
Can't be done.
JavaScript cannot interact with the users system in any way.
The only thing you can do is send a request to a server, which executes the command and sends the response back.
With javascript alone can't be done. But you have at least two option to do this using javascript plus other technologies.
The first one is what Jivings sent, using Jquery to sent a post request to a scripting language at the server side.
The second way is to install Node.js. This platform runs on javascript engine, and has all the features you need from the language. After installing it just see this post that explains how to execute a command.