Ejemplo n.º 1
0
import web
import cla
urls = ('', 'dealshow')


class dealshow():
    def GET(self, *name):
        rend = web.template.render('templ/').showresp(cla.gloresp[1])
        return rend


show = cla.Myapp(urls, locals())
Ejemplo n.º 2
0
import web
import cla
urls = ('', 'deala')


class deala():
    def GET(self, *name):
        rend = web.template.render('templ/').a()
        return rend


pagea = cla.Myapp(urls, locals())
Ejemplo n.º 3
0
            # return str(web.input().addr)
        else:
            return 'None'


class fun1():
    def GET(self):
        addr = str(web.input().addr)
        if len(addr) < 1:
            addr = 'www.z.cn'
        if addr.startswith('http://'):
            addr = addrresp = addr[7:]
        try:
            conn = HC(addr, timeout=100)
            conn.request('GET', '/', headers=heaD)
            resp = conn.getresponse()
            rend = web.template.render('templ/').form
            cla.gloresp = (resp.getheaders(), resp.read(), resp.version,
                           resp.status, resp.reason
                           )  ########baidu return badstatusline
            return rend(cla.gloresp[0], cla.gloresp[1], cla.gloresp[2],
                        cla.gloresp[3], cla.gloresp[4]
                        )  ###########global response, transfer to showresp.py
        except:
            return sys.exc_info(), addr
        finally:
            conn.close()


pageform = cla.Myapp(urls, locals())
Ejemplo n.º 4
0
# except:
# print(sys.exc_info())#################################older
class index():
    def GET(self):
        rend = web.template.render('templ/').index(
            (random.choice(range(50)), random.choice(range(50, 100))))
        return rend


class other():
    def GET(self, *name):
        return 'other here'


class pageb():
    def GET(self):
        # raise web.seeother('/a')##################code 303
        return b.pageb  #####not work


# class Myapp(web.application):
# def run(self,port=int(os.environ.get('PORT', 8080)),*filllater):#########os.environ.get(...),ensure your application makes use of the port assigned to the user environment,on heroku:fill port=int(os.environ.get(...)) instead for heroku dynamic assigned port every start
# func = self.wsgifunc(*filllater)##########must have ?
##print(port)###debug
# return web.httpserver.runsimple(func,('0.0.0.0',port))#####wsgifunc is must filled for runsimple()
##########moved to cla.py      ######################################################
webapp = cla.Myapp(
    urls, locals())  ####deal with application in other code file,port etc.
if __name__ == '__main__':
    webapp.run()
Ejemplo n.º 5
0
import web
# import app
import cla
import os
urls = (
    "",
    'dealb'  #########if '/(.*)' (from web.py official site) instead, response 404,and '(.*)' will catch anything begins with b 
)


class dealb():
    def GET(self, *argvs):
        rend = web.template.render('templ/').b()
        return os.environ.get('PORT'), rend
        # return 'b.py here'


class home():
    def GET(self):
        raise web.seeother('/')


pageb = cla.Myapp(urls, locals())  ##########port spacify needed??
# if __name__ == '__main__':
# pageb.run()################for test