from wsgiref.simple_server import make_server def index(): return 'index' def login(): return 'login' def routes(): urlpatterns=( ('/index',index), ('/login',login), ) return urlpatterns def runserver(environ,start_response): start_response('200 OK' , [('Content-Type','text/html')]) url = environ['PATH_INFO'] urlpatterns = routes() func = None for item in urlpatterns: print (item) if item[0] == url: func=item[1] break if func: a=func() return a else: return 'hhhhh404 404' if __name__ == '__main__': httpd= make_server('192.168.6.163',8000,runserver) print ('start web server') httpd.serve_forever()