def test_subdomains(self): def create_app(name): urls = ("/", "index") class index: def GET(self): return name return web.application(urls, locals()) # fmt: off urls = ("a.example.com", create_app('a'), "b.example.com", create_app('b'), ".*.example.com", create_app('*')) # fmt: on app = web.subdomain_application(urls, locals()) def test(host, expected_result): result = app.request("/", host=host) self.assertEqual(result.data, expected_result) test("a.example.com", b"a") test("b.example.com", b"b") test("c.example.com", b"*") test("d.example.com", b"*")
def main(): web.config.debug = True cfj_app = web.application([ '/([0-9]+[a-z]?)(\.txt)?', 'cfj_num', '/?', 'cfj_main', ], globals()) iw_app = web.application([ '/message/?', 'messages_main', '/message/(.*?)(\.txt)?', 'messages_uid', '/cfj', cfj_app, '/', 'index', ], globals()) app = web.subdomain_application([ 'cfj.qoid.us', cfj_app, '.*', iw_app, ]) app.add_processor(lock_it) app.run()
def test_subdomains(self): def create_app(name): urls = ("/", "index") class index: def GET(self): return name return web.application(urls, locals()) urls = ("a.example.com", create_app("a"), "b.example.com", create_app("b"), ".*.example.com", create_app("*")) app = web.subdomain_application(urls, locals()) def test(host, expected_result): result = app.request("/", host=host) self.assertEquals(result.data, expected_result) test("a.example.com", "a") test("b.example.com", "b") test("c.example.com", "*") test("d.example.com", "*")
def test_subdomains(self): def create_app(name): urls = ("/", "index") class index: def GET(self): return name return web.application(urls, locals()) urls = ("a.example.com", create_app('a'), "b.example.com", create_app('b'), ".*.example.com", create_app('*')) app = web.subdomain_application(urls, locals()) def test(host, expected_result): result = app.request('/', host=host) self.assertEquals(result.data, expected_result) test('a.example.com', 'a') test('b.example.com', 'b') test('c.example.com', '*') test('d.example.com', '*')
async def test_subdomains(self): def create_app(name): urls = ("/", "index") class index: def GET(self): return name return web.application(urls, locals()) urls = ("a.example.com", create_app("a"), "b.example.com", create_app("b"), ".*.example.com", create_app("*")) app = web.subdomain_application(urls, locals()) async def test(host, expected_result): result = await app.request("/", host=host) self.assertEqual(result.data, expected_result) await test("a.example.com", b"a") await test("b.example.com", b"b") await test("c.example.com", b"*") await test("d.example.com", b"*")
def test_subdomains(self): def create_app(name): urls = ("/", "index") class index: def GET(self): return name return web.application(urls, locals()) urls = ( "a.example.com", create_app('a'), "b.example.com", create_app('b'), ".*.example.com", create_app('*') ) app = web.subdomain_application(urls, locals()) def test(host, expected_result): result = app.request('/', host=host) self.assertEqual(result.data, expected_result) test('a.example.com', b'a') test('b.example.com', b'b') test('c.example.com', b'*') test('d.example.com', b'*')
import string import random from datetime import datetime, timedelta update_app = web.application(( '/(.*)', 'web_update', ), globals()) info_app = web.application(( '/?', 'web_index', '/register', 'web_register', '/reset', 'web_reset', '/passwd', 'web_passwd', ), globals()) app = web.subdomain_application(( "master[46]\..*", update_app, ".*", info_app, )) class web_index: def GET(self): web.header('Vary', '*') return __doc__.strip() % { "hostname": web.ctx.env["HTTP_HOST"], } class web_register: def POST(self): web.header('Content-Type', 'text/plain')