【发布时间】:2016-10-05 23:48:01
【问题描述】:
我正在尝试安装和运行 python 金字塔。
我安装了anaconda,创建了一个虚拟环境并使用pip install "pyramid==1.7.3"安装了金字塔。
然后执行
`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', '/hello/{name}')
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()`
这个helloworld.py。这不会启动服务器,当我在浏览器中打开 localhost:8080 时,它给了我一个 404 Not Found The resource could not be found. 错误。
我在这里错过了什么?
【问题讨论】:
-
您的服务器已启动并正在运行。尝试使用“localhost:8080/hello/john”
-
是的,它服务于“localhost:8080/hello/world”
标签: pyramid