pip install tg.devtools tg-admin quickstart python from tg import expose, TGController, AppConfig python class ApiController(TGController): pass python class ApiController(TGController): @expose() def get_data(self, *args, **kwargs): data = {'message': 'Hello, World!'} return data @expose('json') def post_data(self, *args, **kwargs): data = {'message': 'Data created successfully.'} return data python from routes import Mapper def add_routes(web_config): map = Mapper(directory=config["pylons.paths"]["controllers"]) map.connect('api', '/api/{action}/{id}', controller='api') web_config.update({'routes.map': map}) paster serve development.ini


上一篇:
下一篇:
切换中文