Flask App With Spark

[Solved] Flask App With Spark | Python Frameworks Flask - Code Explorer | www.yomemimo.com
Question : flask app with spark

Answered by : obnoxious-ox

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!

Source : https://stackoverflow.com/questions/32719920/access-to-spark-from-flask-app | Last Update : Tue, 24 Mar 20

Answers related to flask app with spark

Code Explorer Popular Question For Python Frameworks Flask