Flask, CherryPy and static content

后端 未结 1 520
挽巷
挽巷 2021-02-06 06:10

I know there are plenty of questions about Flask and CherryPy and static files but I still can\'t seem to get this working.

There\'s a snippet to deploy a Flask app on C

相关标签:
1条回答
  • 2021-02-06 06:25

    Here is a snippet that should do what you are asking for. This is based on the set of instructions provided here (it's definitely worth a read, though I'm not sure how up to date it is).

    import cherrypy
    from hello import app
    
    cherrypy.tree.graft(app, '/')
    cherrypy.tree.mount(None, '/static', {'/' : {
        'tools.staticdir.dir': app.static_folder,
        'tools.staticdir.on': True,
        }})
    cherrypy.config.update({
        'server.socket_port': 8080,
        })
    cherrypy.engine.start()
    cherrypy.engine.block()
    
    0 讨论(0)
提交回复
热议问题