TurboGears是为Pytho提供网页前端到后端整合的网站框架,让网站开发更加快速和容易。
安装pip:
$curl-O'https://bootstrap.pypa.io/get-pip.py'$pythoget-pip.py安装 Turbogears:
$pipistallTurboGears2开发一个简单的TGweb应用:
fromwsgiref.simple_serverimportmake_serverfromtgimportMiimalApplicatioCofiguratorfromtgimportexpose,TGCotroller#RootCotrollerofourwebapp,ichargeofservigcotetfor/classRootCotroller(TGCotroller):@expose(cotet_type="text/plai")defidex(self):retur'HelloWorld'#Cofigureaewmiimalapplicatiowithourrootcotroller.cofig=MiimalApplicatioCofigurator()cofig.update_blueprit({'root_cotroller':RootCotroller()})#Servetheewlycofiguredwebapplicatio.prit("Servigoport8080...")httpd=make_server('',8080,cofig.make_wsgi_app())httpd.serve_forever()使用命令 pythowebapp.py 启动,并打开浏览器访问 https://localhost:8080/
安装指南:https://docs.turbogears.org/1.0/Istall








评论