本文整理汇总了Python中vertx.create_http_server函数的典型用法代码示例。如果您正苦于以下问题:Python create_http_server函数的具体用法?Python create_http_server怎么用?Python create_http_server使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了create_http_server函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_http
def test_http():
# Create an HTTP server which just sends back OK response immediately
def req_handler(req):
req.response.end()
def resp_handler(resp):
VertxAssert.assertTrue(200 == resp.status_code)
# If we get here, the test is complete
# You must always call `testComplete()` at the end. Remember that testing is *asynchronous* so
# we cannot assume the test is complete by the time the test method has finished executing like
# in standard synchronous tests
VertxAssert.testComplete()
def listen_handler(err, server):
VertxAssert.assertNull(err)
# The server is listening so send an HTTP request
vertx.create_http_client().set_port(8181).get_now("/", resp_handler)
vertx.create_http_server().request_handler(req_handler).listen(8181, "0.0.0.0", listen_handler)
开发者ID:normanmaurer,项目名称:mod-smtpserver,代码行数:20,代码来源:basic_integration_test.py
示例2: handle
# Copyright 2011 the original author or authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import vertx
server = vertx.create_http_server(ssl=True)
server.key_store_path = "server-keystore.jks"
server.key_store_password = "wibble"
@server.request_handler
def handle(req):
req.response.end("<html><body><h1>Hello from vert.x over HTTPS!</h1></body></html>")
server.listen(4443)
开发者ID:Ed42,项目名称:vertx-examples,代码行数:25,代码来源:https_server.py
示例3: handle
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import vertx
server = vertx.create_http_server()
@server.request_handler
def handle(req):
print "Got request %s"% req.uri
for header in req.headers.keys():
print "%s : %s"% (header, req.headers[header])
@req.data_handler
def data_handler(data):
print "Got data %s"% data
@req.end_handler
def end_handler():
req.response.chunked = True
开发者ID:Ed42,项目名称:vertx-examples,代码行数:31,代码来源:http_server.py
示例4: RouteMatcher
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import vertx
from core.http import RouteMatcher
# Inspired from Sinatra / Express
rm = RouteMatcher()
def user_request_handler(req):
req.response.end("User: %s ID: %s"% (req.params["user"], req.params["id"]) )
# Extract the params from the uri
rm.get('/details/:user/:id', user_request_handler)
def request_handler(req):
req.response.send_file("route_match/index.html")
# Catch all - serve the index page
rm.get_re('.*', request_handler)
vertx.create_http_server().request_handler(rm).listen(8080)
开发者ID:Ed42,项目名称:vertx-examples,代码行数:30,代码来源:route_match_server.py
注:本文中的vertx.create_http_server函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论