how to display ruby output in browser? [closed] - html

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
Am learning ruby scripting language. I was implementing exercises in ruby.
In that I had a one problem. I need to display the ruby output in browser.
For example, I have a one ruby script, named hello.rb. It will print the "Hello world message". Normally if we execute this with ruby interpreter it will print that in the terminal. I need to print that hello world message in the browser by invoking the ruby script.
For that I was referred in the internet. In that they told that you need to install gem 'tilt'.
Without installing any gems how can we achieve this ?
Thanks in Advance!

Ruby comes with a simple web server, webrick. The following code uses webrick to implement a simple "hello, world" web server:'
require "webrick"
server = WEBrick::HTTPServer.new(Port: 8000)
server.mount_proc "/" do |req, res|
res.body = "Hello, world!\n"
end
server.start
When run, it prints some log output to show that it is running and ready to serve requests:
[2016-07-22 12:02:01] INFO WEBrick 1.3.1
[2016-07-22 12:02:01] INFO ruby 2.3.1 (2016-04-26) [x86_64-linux]
[2016-07-22 12:02:01] INFO WEBrick::HTTPServer#start: pid=16318 port=8000
I used the *nix utility curl to give the server a request:
wayne#treebeard:~$ curl localhost:8000
Hello, world!
Although I used curl, any web browser would also work. After starting the program, send your web browser to:
http://localhost:8000

Related

Why Use Argo CD in Combination with Tekton [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 1 year ago.
Improve this question
I am configuring a cloud-native OpenShift CI/CD process using Tekton. Tekton has the option to trigger via events and also has the option to deploy directly to a cluster. Given this functionality, I am confused of the ideal use case for Argo CD.
Argo CD appears to share very similar functionality with Tekton except lacks the ability to run builds. If I can build and deploy apps entirely via Tekton, what advantage does Argo provide?
It's a matter of preference.
Yes, Tekton is good for a Build Pipeline and can also be used for deployment.
There are many different ways to deploy to Kubernetes
With kubectl apply -f using declarative manifests
With kubectl apply -k using kustomization (e.g. to easier maitain multiple environments)
With ArgoCD, using GitOps to sync a git repository to the cluster, see example in a Tekton Pipeline
With kpt that is similar to kustomize but can manage "bundles" from git
With helm, using templates and charts
With flagger to use e.g. Canary Deployments
They can all deploy to Kubernetes. Which method you use depends on your preferences.

An unhandled exception occurred: Port 4200 is already in use. Use '--port' to specify a different port [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
I tried to access localhost:4200 on my browser for my project. And the compile error message showed up each time I opened localhost4200. It says port 4200 is already in use. I tried online method like Ctrl+C but it doesn't work and have the error message shows up again. Could you help me with this problem? Thanks! The first screenshot is what my browser web page looks like when I go to localhost 4200.
This is what showed me in the terminal window after I run npm start. I could not run ng serve for some reasons. But the npm start works fine for me before.
You can kill the port with:
kill $(lsof -ti:4200)
And then run ng serve again.
Although you have two different problems that are most likely not connected. The error you're seeing in the browser is due to a code error which we'd need more information to help you fix.
This was in my archive. How to kill all node processes on a windows machine? taskkill /F /IM node.exe
Here is another way to do it.
killall node
if you're using windows ,then you can use netstat -ano|findstr 4200 to get the pid
then you can use taskkill /f /t /im yourpid to close 4200 port,then start it again .hope it could help you
You can kill the task that is running on 4200 or just use ng serve --port 4201

running a shell script from html [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 8 years ago.
Improve this question
I have created two virtual machines having ubuntu 12.04 lts os. Installed apache tomcat 7 on both VM's (virtual machine). configured virtual private network.
HTTP request on VM1 should run a shell script on VM2 and return the result to VM1 as an html file. I did the configuration part.
Now i need to know, how to write an HTML response file in VM2 server(which can be displayed on VM1 browser as a response) which will invoke a shell script having "ps -Aef" command to list all processes running on VM2. i need to display the contents of this file on VM1.
since i am a beginner in web programming/shell scripting please help me.
Thank you in advance
-Akshay
You can use PHP
Install php (apt-get install php)
copy index.php file into /var/www/html folder
index.php
<?php
$output = shell_exec('ps -Aef');
echo "<pre>$output</pre>";
?>
browse http://<ip-address>/index.php
What you need is a web server that can run CGI scripts. It's too long to completely list the steps of setting up CGI (and it depends on your web server of choice etc.). But considering you are a beginner, there is a pretty extensive tutorial with examples on how to configure Apache to run CGI scripts right here.
To summarize:
You need to install Apache (apt-get install apache2)
Configure Apache to enable mod_cgi as described in the tutorial above.
Write your first CGI program and test it (also in that tutorial).

"reading files list for package 'inkscape': Input/output error" while trying to install packages [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 9 years ago.
Improve this question
It doesn't matter what I try to install using my package manager(sudo apt-get install whatever), I always get this error.
dpkg: unrecoverable fatal error, aborting:
reading files list for package 'inkscape': Input/output error
E: Sub-process /usr/bin/dpkg returned an error code (2)
I have researched and have tried to rebuild my dpkg status file, and I have also tried to revert to an older version, but it either hasn't worked or I am doing it wrong.
Also, when I try to run the command "sudo apt-get update", I get this error.
The problem started when I lost my internet connection while downloading monodevelop. Any help is greatly appreciated.
I figured out the answer, so I will post it here in case anybody else has the same problem in the future.
NOTE: After this fix, apt-get no longer installs dependencies for me automatically without using the -f flag.
Go into the /var/lib/dpkg directory
Make a backup of the "status" file
Open the status file as root and find the package that causes the error.
In this case, its "PACKAGE: inkscape".
Delete all the text until the next PACKAGE: declaration in the file.

Compile CMU PocketSphynx at Linux Mint 13 [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
I've installed CMU Sphynx at Linux Mint 13 (based on Ubuntu 12.04 LTS) and I simply cant' find any examples for:
How to just test how it work in most simple way? I want to launch it from command line and recognize any .wav file. I've read docs but there are just c++ or python examples, no examples for pocketsphynx_continious
Where can I get /dev/dsp devise at Mint? I have installed all dev libs for alsa and pulseaudio - no /dev/dsp at all.
Any help?
To recognize from microphone
pocketsphinx_continuous
To recognize a file (16khz mono 16bit)
pocketsphinx_continuous -infile file.wav
To create /dev/dsp you need to load kernel driver for oss
modprobe snd_pcm_oss
Development libs are for development, not for /dev/dsp. After you installed development libraries, you need to recompile and reinstall sphinxbase. It will detect development libraries and use alsa instead of oss.