我試圖更改Pyramid hello world example,以便對金字塔服務器的任何請求都服務於同一頁面。即所有路線指向相同的視圖。這是第四走到這一步:Python Pyramid中所有地址轉到單個頁面(捕獲全部路徑)
from wsgiref.simple_server import make_server
from pyramid.config import Configurator
from pyramid.response import Response
def hello_world(request):
return Response('Hello %(name)s!' % request.matchdict)
if __name__ == '__main__':
config = Configurator()
config.add_route('hello', '/*')
config.add_view(hello_world, route_name='hello')
app = config.make_wsgi_app()
server = make_server('0.0.0.0', 8080, app)
server.serve_forever()
完成所有四是改變(從Hello World示例)行:
config.add_route('hello', '/hello/{name}')
要:
config.add_route('hello', '/*')
所以我想路線是一個'全面'。 Iv嘗試了各種變化,無法讓它工作。有沒有人有任何想法?
感謝addvance
致謝這正是即時尋找!我幾次查看了文檔的這一部分,但我只是不習慣術語,所以沒有點擊。謝謝 – joshlk