Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7087287
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T07:39:21+00:00 2026-05-28T07:39:21+00:00

My goal is to define a RESTful api using CherryPy (wsgi) + uWSGI +

  • 0

My goal is to define a RESTful api using CherryPy (wsgi) + uWSGI + Nginx. I’m wondering how to handle the OPTIONS method, as suggested to me on #python. I was advised that implementing a handler to this method would help the callers to my api to understand what methods are supported, and what methods aren’t.

Here’s what I’ve got so far:


#!/usr/bin/env python

import cherrypy

# modules used for data access
import nosql
import dao

class Product(object):

    exposed = True

    def GET(self, key, *args, **kwargs):
        try:
            p = Product(nosql.get(key))
            return p.json
        except:
            # return 500 error with traceback if debug
            pass

    def POST(self, *args, **kwargs):
        try:
            p = dao.Product(*args, **kwargs)
            k = nosql.generate_key(Product.__name__)
            nosql.set(k,str(p))
        except:
            # return 500 error with traceback if debug
            pass

    def OPTIONS(self, *args, **kwargs):
        """
        The question is, what to return here?  I'm looking 
        at the following rfc:

        http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html
        """
        return "GET, POST"

conf = {
    '/': {
        'request.dispatch':cherrypy.dispatch.MethodDispatcher(),
    },
}

application = cherrypy.tree.mount(Product, config=conf)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T07:39:21+00:00Added an answer on May 28, 2026 at 7:39 am

    The body of the OPTIONS response is not as important, and certainly not as specified, as the headers. As you mention, most clients are really only interested in the methods. Those are specified in the “Allow” response header, which CherryPy helpfully emits automatically when you use the MethodDispatcher. Anything else you might return is really up to you to try to meet the needs of the client’s application.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

First off, let me define the end goal: I'd like to Wordpress (version 2.8)
Goal Java client for Yahoo's HotJobs Resumé Search REST API . Background I'm used
Goal: Create Photomosaics programmatically using .NET and C#. Main reason I'd like to do
My goal is to be able to define a class for the element in
The Java Collections interfaces (for example, List or Set ) define the contains method
How do I define an Extension Method for IEnumerable<T> which returns IEnumerable<T> ? The
I'm trying to generate a function declaration using a macro /* goal: generate int
I am trying to make a library that accesses an online RESTful API. The
Goal: implement unfold function using only two arguments. The arguments: the first argument is
I am trying to define interface types in C++ using abstract classes and implement

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.