Ruby Remote Control script

Source: Internet
Author: User

Sometimes, we need the server to control the remote server to do some things, while stable and reliable, will not suddenly hang out or anything.

Then Ruby is a great tool.

# encoding:utf-8#!/usr/bin/ruby# encoding:utf-8# Port 1990# Browser access: Http://127.0.0.1:1990/hello/passwordrequire ' Sinatra /base ' require ' json ' require ' net/http ' class Hello < Sinatra::base set:p ort, 1990 Set:bind, ' 0.0.0.0 ' set:environm ENT,:p roduction get '/hello/:p wd ' Do {result:1, message: ' Hello '}.to_json End class << self DEF init p UTS ' init ' end end init run!end

Based on the very well-known Sinatra web framework, a very nice mini-frame, just a few lines of code to implement a Web program, which is used to run remote scripting, stable and reliable. Of course, you can also use your own webbrick, but the code doesn't look comfortable.

Ruby Run.rb ran up.


Ruby Remote Control script

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.