我试图建立一个JSON的服务与动态路由:/动作/ {ID}金字塔路由问题
我收到了404,当我浏览到:http://example.com:8080/action/test
基于this documentation,似乎像我的路由配置正确,但它不是。
任何想法我在做什么错在这里?
from wsgiref.simple_server import make_server
from pyramid.config import Configurator
from pyramid.view import view_config
@view_config(route_name="action", renderer="json")
def run_action(self):
id = self.request.matchdict['id']
return {'id': id}
def main():
config = Configurator()
config.add_route('action', '/action/{id}')
app = config.make_wsgi_app()
return app
if __name__ == '__main__':
app = main()
server = make_server('0.0.0.0', 8080, app)
server.serve_forever()
它与OP的问题没有直接关系,所以我只是将其作为评论。我在金字塔应用程序中遇到了404个问题。 'config.scan'调用和'@ view_config'装饰器都已就位。我的问题显然是,我有两个具有不同'@ view_config'装饰的名称相同的方法。 – skytreader