Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

flask app with spark

from pyspark import SparkContext
sc = SparkContext('local')

from flask import Flask, request
app = Flask(__name__)

@app.route('/whateverYouWant', methods=['POST'])  #can set first param to '/'

def toyFunction():
    posted_data = sc.parallelize([request.get_data()])
    return str(posted_data.collect()[0])

if __name__ == '__main_':
    app.run(port=8080)    #note set to 8080!
Comment

PREVIOUS NEXT
Code Example
Python :: slack bot error not_in_channel 
Python :: multi threading in python for 2 different functions with return 
Python :: merge 2 dataframes in python 
Python :: wap in python to check a number is odd or even 
Python :: pylab plotting data 
Python :: gyp err! stack error: command failed: c:python39python.exe -c import sys; print "%s.%s.%s" % sys.version_info[:3]; 
Python :: text classification 
Python :: post list python 
Python :: django authenticate with email 
Python :: create virtual environment python stack overflow 
Python :: flask where to put db.create_all 
Python :: rename colums dataframe pandas 
Python :: python selenium print element 
Python :: python conditions 
Python :: check audio playing on windows python 
Python :: python os.path.join 
Python :: how to code a trading bot in python 
Python :: django render example 
Python :: pdf to string python 
Python :: how to serach for multiple attributes in xpath selenium python 
Python :: python keyboard hold key 
Python :: how to get more than one longest word in a list python 
Python :: create_polygon tkinter 
Python :: a list of keys and a list of values to a dictionary python 
Python :: array with zeros python 
Python :: python string starts with any char of list 
Python :: python get type of variable 
Python :: django email 
Python :: fill zeros left python 
Python :: python check if string or list 
ADD CONTENT
Topic
Content
Source link
Name
9+2 =