“Estrutura de funções do CORS Python” Respostas de código

CORS Python

pip install django-cors-headers 
Fuck Coder

Estrutura de funções do CORS Python

def the_function(request):
    # Return CORS headers on OPTIONS request.
    if request.method == 'OPTIONS':
        headers = {
            'Access-Control-Allow-Origin': '*',
            'Access-Control-Allow-Methods': 'GET',
            'Access-Control-Allow-Headers': 'Content-Type',
            'Access-Control-Max-Age': '3600'
        }
        return ('', 204, headers)
    
    # If the request is GET then handle it normally
    if request.method == 'GET':
        x = request.args('x')
        y = request.args('x')
        result = int(x) * int(y)
        headers = {
            'Access-Control-Allow-Origin': '*'
        }
        return (result, 200, headers)
     else:
        # If the request is not GET or OPTIONS, deny.
        return '', 400
jstncno

Respostas semelhantes a “Estrutura de funções do CORS Python”

Perguntas semelhantes a “Estrutura de funções do CORS Python”

Mais respostas relacionadas para “Estrutura de funções do CORS Python” em Python

Procure respostas de código populares por idioma

Procurar outros idiomas de código