Re: REST web service in CherryPy within Apache via WSGI
Dileep S <[email protected]>
| Newsgroups | gmane.comp.python.cherrypy |
|---|---|
| Message-ID | <[email protected]> |
Hi Gerold,
Thank you for the solution
We configured httpd.config file as you suggested. It is saying still status
404
Do we need to anythinelse?
On Friday, 5 August 2011 16:39:18 UTC-4, Gerold Penz wrote:
> Hello!
>
> Am 2011-08-05 16:04, schrieb The Cleric:
> > and now would like to migrate it into an Apache server so
> > that I don't have to keep it running as a separate server on a
> > separate port.
> > 1) Is this possible?
>
> Yes, of course!
>
> > 2) How do I do it?
>
> mod_wsgi is a good way for it.
>
> #!/usr/bin/env python
> #coding: utf-8
>
> # myproject.py
>
> import os
> import sys
> import cherrypy
>
>
> class Root(object):
> def index(*args, **kwargs):
> return "Hello World"
> index.exposed = True
>
>
> def get_app():
> app = cherrypy.tree.mount(Root())
> return app
>
>
> def get_wsgi_app():
> app = get_app()
> config = {
> "environment": "embedded",
> "log.screen": False,
> "show_tracebacks": False,
> "engine.autoreload_on": False,
> }
> cherrypy.config.update(config)
> return app
>
>
> def main():
> app = get_app()
> cherrypy.quickstart(app)
>
>
> if __name__ == "__main__":
> main()
>
>
> #!/usr/bin/env python
> #coding: utf-8
>
> # myproject.wsgi
>
> import os
> import cherrypy
> import sys
> sys.stdout = sys.stderr
>
> THISDIR = os.path.dirname(os.path.abspath(__file__))
> sys.path.insert(0, THISDIR)
>
> import myproject
>
> application = myproject.get_wsgi_app()
>
> <VirtualHost *:80>
>
> DocumentRoot /home/myusername/public
>
> AddDefaultCharset utf-8
> AddCharset utf-8 .css .js .html .xml .json .rss
>
> <Directory /home/myusername/myproject>
> AllowOverride All
> Order deny,allow
> Allow from all
> </Directory>
>
>
> # WSGI
> WSGIDaemonProcess myproject user=myusername group=myusername
> processes=2 threads=5
> WSGIScriptAlias / /home/myusername/myproject/myproject.wsgi
> #WSGIDaemonProcess myproject user=myusername group=myusername
> threads=5
> #WSGIScriptAlias / /home/myusername/myproject/myproject.wsgi
>
> <Directory /home/myusername/myproject>
> WSGIProcessGroup myproject
> WSGIPassAuthorization On
> </Directory>
>
> </VirtualHost>
>
>
> Regards,
> Gerold
> :-)
>
>
> --
> Gerold Penz - http://halvar.at
> Wissen hat eine wunderbare Eigenschaft:
> Es verdoppelt sich, wenn man es teilt.
>
>
--
You received this message because you are subscribed to the Google Groups "cherrypy-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cherrypy-users+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/[email protected]
To post to this group, send email to cherrypy-users-/JYPxA39Uh5TLH3MbocFF+G/[email protected]
Visit this group at https://groups.google.com/group/cherrypy-users.
For more options, visit https://groups.google.com/d/optout.