예제 #1
0
    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"*")
예제 #2
0
파일: iwmain.py 프로젝트: comex/agora-infra
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()
예제 #3
0
파일: application.py 프로젝트: hyh626/webpy
    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", "*")
예제 #4
0
    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', '*')
예제 #5
0
    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"*")
예제 #6
0
 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'*')
예제 #7
0
파일: ddnsapp.py 프로젝트: shish/tidydns
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')