LoginSignup
2
2

More than 5 years have passed since last update.

trusterdでリクエストを受け付けてみた

Last updated at Posted at 2015-02-06

やり方

trusterd.conf.rbを編集する。

callbackをtrueにしてHTTP2サーバーを生成する。

s = HTTP2::Server.new({
:port           => 8080,
  :document_root  => "#{root_dir}/htdocs",
  :server_name    => SERVER_DESCRIPTION,
  :worker         => "auto",
  :key            => "#{root_dir}/ssl/key.pem",
  :crt            => "#{root_dir}/ssl/cert.pem",
  :callback => true,
})

callbackの設定

s.set_map_to_strage_cb {
  if s.request.uri == "/py_exec"
    # PyCall.py_exec("print('Hello,This is trusterd!')")
    puts "test!"
    # 表示はindex.html
    s.request.filename = "#{root_dir}/htdocs/index.html"
  end

試す

ChromeやFirefoxで

https://127.0.0.1:8080/py_exec

関連投稿

2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2