0

I dont want a config file only for cherrypy. I need it only for a very smallish webserver which wont be actually accesible to the world, so no need for me to mock around in config files.

Is there a way to pass a "config" to wsgiserver when starting it? I just need a 5-10 line script to fire of a threading web server, which can run a flask application and server static files.

Also, I dont want to specify full path to the static files, just ./static from where the script is ran.

rapadura
  • 5,242
  • 7
  • 39
  • 57

1 Answers1

0

According to Changing default url to static-media in Flask the only option is to map /static to something that serves from os.getcwd() + '/static'.

Or with CherryPy: How to use cherrypy as a web server for static files?

Community
  • 1
  • 1
Cees Timmerman
  • 17,623
  • 11
  • 91
  • 124
  • Yes I know flask can do it, but I dont want to server static files with flask since I am already serving the flask application using cherrypy. I want cherrypy to serve the static files under ./static and run the flask app. – rapadura Nov 21 '11 at 09:28
  • I've updated my answer for working directory file serving using CherryPy. – Cees Timmerman Nov 21 '11 at 10:21
  • Aha, I see. Can I pass a config to serve static using wsgiserver.CherryPyWSGIServer – rapadura Nov 21 '11 at 10:31
  • 1
    It appears that a CherryPy tree does WSGI callables: http://docs.cherrypy.org/dev/refman/tree.html – Cees Timmerman Nov 21 '11 at 10:52
  • This post might also be useful: http://rhodesmill.org/brandon/2011/wsgi-under-cherrypy/ – Cees Timmerman Nov 21 '11 at 11:00
  • Hmm, Ill look whats under .tree. Any reason why the cherrypy docs dont mention it? The documentation in general is very lacky for cherrypy. – rapadura Nov 21 '11 at 12:08
  • Maybe they assume you'll use `dir(mystery_object)`, but documentation tends to be an afterthought. CherryPy's isn't too bad, but not as great as PHP's. The merge function also looks promising: http://docs.cherrypy.org/dev/refman/_cptree.html?highlight=tree#cherrypy._cptree.Tree – Cees Timmerman Nov 21 '11 at 12:23
  • I have used dir and help on some cherrypy stuff to learn about it, and had to look in the source to understand other stuff. But documentation should be there to tell me the .tree is not an internal cherrypy "make-it-work"-thing like cherrypy.engine is. The documentation told me to use wsgiserver.CherryPyWSGIServer to start/stop it, now suddenly I have to use .engine and .tree in combination. Still strange to say engine.start() to run a http server. Bah, anyway... django has really nice documentation. Wish cherrypy had too. The threading server is still worth it... – rapadura Nov 21 '11 at 12:52