【问题标题】:Python- pyramid doesn't run local hostPython-金字塔不运行本地主机
【发布时间】: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. 错误。

这里是Command Prompt

我在这里错过了什么?

【问题讨论】:

  • 您的服务器已启动并正在运行。尝试使用“localhost:8080/hello/john”
  • 是的,它服务于“localhost:8080/hello/world

标签: pyramid


【解决方案1】:

对于使用 Python 进行 Web 应用程序开发的新手,我建议使用 Quick Tutorial。不要跳过任何步骤,包括要求。它很好地概述了在 Python 及其生态系统中创建 Web 应用程序,并提供了进一步深入阅读的参考资料。

Anaconda 面向数据科学受众。在我们的文档中,我们没有提供有关如何在 Anaconda 中工作的具体说明,因此您必须自己学习这部分内容。

【讨论】:

    【解决方案2】:

    它服务于“http://localhost:8080/hello/world”而不是“localhost:8080”

    【讨论】:

      猜你喜欢
      • 2014-12-29
      • 1970-01-01
      • 1970-01-01
      • 2020-12-13
      • 2015-12-19
      • 2016-08-20
      • 1970-01-01
      • 1970-01-01
      • 2012-09-14
      相关资源
      最近更新 更多