Files
fission-src/environments/python3/server.py
T
Soam Vasani 640e65f35f Use Flask for Python environment
Flask gives us easy routing support, and simple interface for getting
at request data.
2016-11-19 20:04:46 -08:00

33 lines
690 B
Python

#!/usr/bin/env python
import imp
from flask import Flask
from flask import request
from flask import abort
app = Flask(__name__)
codepath = '/userfunc/user'
userfunc = None
@app.route('/specialize', methods=['POST'])
def load():
global userfunc
userfunc = (imp.load_source('user', codepath)).main
return ""
@app.route('/', methods=['GET', 'POST', 'PUT', 'HEAD', 'OPTIONS', 'DELETE'])
def f():
if userfunc == None:
print("Generic container: no requests supported")
abort(500)
return userfunc()
#
# TODO: this starts the built-in server, which isn't the most
# efficient. We should use something better.
#
app.run(host='0.0.0.0', port='8888')