2017-07-18 13:03:20 +00:00
|
|
|
from flask import Flask,send_from_directory,request
|
2017-07-12 06:40:24 +00:00
|
|
|
app = Flask(__name__,static_url_path='',static_folder='build')
|
2017-07-19 11:23:24 +00:00
|
|
|
# from freespeech_walle.get_morph_rule import get_morph
|
|
|
|
|
from freespeech_walle.wizard_helpers import get_morph_rule,get_frequency
|
2017-07-18 13:03:20 +00:00
|
|
|
import json
|
2017-07-12 06:40:24 +00:00
|
|
|
|
2017-07-19 11:23:24 +00:00
|
|
|
# from flask_cors import CORS, cross_origin
|
|
|
|
|
# CORS(app)
|
|
|
|
|
|
2017-07-12 06:40:24 +00:00
|
|
|
@app.route('/')
|
2017-07-12 07:55:24 +00:00
|
|
|
def walle_index():
|
2017-07-12 06:40:24 +00:00
|
|
|
return app.send_static_file('index.html')
|
2017-07-12 07:55:24 +00:00
|
|
|
|
|
|
|
|
|
2017-07-19 11:23:24 +00:00
|
|
|
@app.route('/api/test')
|
2017-07-12 07:55:24 +00:00
|
|
|
def walle_test():
|
|
|
|
|
return "test"
|
2017-07-13 11:38:27 +00:00
|
|
|
|
2017-07-19 11:23:24 +00:00
|
|
|
@app.route('/api/morph')
|
2017-07-18 13:03:20 +00:00
|
|
|
def walle_morph():
|
2017-07-19 11:23:24 +00:00
|
|
|
word = request.args.get('word','water')
|
|
|
|
|
pos_req = request.args.get('pos','N')
|
|
|
|
|
pos = pos_req if pos_req != '' else 'N';
|
|
|
|
|
return json.dumps(get_morph_rule.get_morph(word,pos))
|
2017-07-18 13:03:20 +00:00
|
|
|
|
2017-07-18 10:24:19 +00:00
|
|
|
# hmr streaming
|
2017-07-18 13:03:20 +00:00
|
|
|
# import requests
|
2017-07-18 10:24:19 +00:00
|
|
|
# from flask import Response,stream_with_context
|
2017-07-18 10:59:16 +00:00
|
|
|
# @app.route('/<path:url>',methods=['GET','POST'])
|
2017-07-18 10:24:19 +00:00
|
|
|
# def walle_hmr(url):
|
2017-07-18 10:59:16 +00:00
|
|
|
# webpack_server = 'http://localhost:3000/'
|
2017-07-18 10:24:19 +00:00
|
|
|
# req = requests.get(webpack_server+url, stream = True)
|
2017-07-18 10:59:16 +00:00
|
|
|
# return Response(stream_with_context(req.iter_content()))
|
2017-07-18 10:24:19 +00:00
|
|
|
|
2017-07-13 11:38:27 +00:00
|
|
|
if __name__ == '__main__':
|
|
|
|
|
app.run(debug=True)
|