Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

cors python functions framework local

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
Comment

PREVIOUS NEXT
Code Example
Python :: programação funcional python - append 
Python :: django models get all 
Python :: port python script to jupyter notebook 
Python :: networkx draw edge description 
Python :: how to get coupons from honey in python 
Python :: Get the positions of items of ser2 in ser1 as a list python 
Python :: transverse tensor in pytorch 
Python :: Python - Comment convertir la corde à la date 
Python :: 201903100110041 
Python :: online python debugger 
Python :: jpg image in tkinter title 
Python :: numpy array majority and how many 
Python :: countvectorizer remove stop words 
Python :: odoo - add one2many field programmatically 
Python :: Kinesis Client get_records example 
Python :: how to reverse a dictionary in python 
Python :: declare variable in python 
Python :: The print() Function 
Python :: Herons rule python 
Python :: pandas set column to value using mask 
Python :: omr sheet python stackoverflow 
Python :: how to print the text new line instead of n in jupyter notebook 
Python :: check if a date is reached django 
Python :: c Pythagorean triples 
Python :: queryset.raw() in django rest framework joining tables 
Python :: keep only min entries in dataframe grouped by one column 
Python :: create animation from sequence of image python 
Python :: train_ttest_split() 
Python :: terneray operator in python 
Python :: Random Remarks Example in python 
ADD CONTENT
Topic
Content
Source link
Name
4+2 =