[Python] How to use Pyramid?
程序员文章站
2022-07-07 20:51:05
in this blog, i will tell you how to use pyramid by codes.
'''
the start point is the conf...
in this blog, i will tell you how to use pyramid by codes.
''' the start point is the configurator class.use it to configure the routes and views, give application back to wsgi server finally. the class configurator inherits many classes.it is a big mix and has great power. ''' from wsgiref.simple_server import make_server from pyramid.config import configurator from pyramid.response import response def hello(request): return response("this is my small application") def page(request): return response("this is another page") def main(): config = configurator() config.add_route('hello', '/') config.add_route('test','/test') config.add_route(name="page",pattern="/page",view=page) config.scan('view') config.add_view(view=hello,route_name="hello") app = config.make_wsgi_app() return app if __name__ == '__main__': app = main() server = make_server('127.0.0.1', 8080, app) print ('starting up server on https://localhost:8080') server.serve_forever()
上一篇: (转载)thymeleaf关于js的一些坑(数组定义)
下一篇: python读取xml文件
推荐阅读
-
How to use special characters in XML?
-
[Python]How to use magic methods in Python?
-
How to Use HTML5 FUll Screen API(如何使用HTML5全屏接口)
-
「Python」Linux环境下启动Flask应用时失败,Error:Address already in use
-
How to use HttpClient HttpClient
-
Bash - how to use sendmail
-
How to use provided scope for jar file in Gradle build?
-
[Python] How to use Pyramid?
-
How to use VS2019 to Compile PhysX-4.0.0
-
Day 4--robot api with yaml: Use your python scripts as robot keywords