Commit 9851cf9e authored by Jérome Perrin's avatar Jérome Perrin

server: workaround for Infinity beeing serialised by server and not supported by javascript

parent 67486af2
...@@ -34,11 +34,22 @@ import os.path ...@@ -34,11 +34,22 @@ import os.path
import logging import logging
import simpy import simpy
from flask import Flask, jsonify, redirect, url_for from flask import Flask
from flask import request from flask import request
from flask import jsonify, redirect, url_for
from flask.json import JSONEncoder
app = Flask(__name__) app = Flask(__name__)
class InfinityJSONEncoder(JSONEncoder):
# we don't serialise inf, as javascript does not load it.
def iterencode(self, *args, **kw):
for j in JSONEncoder.iterencode(self, *args, **kw):
if "Infinity" in str(j): # XXX the replace should not be so "global"
j = j.replace("Infinity", str(2**64))
yield j
app.json_encoder = InfinityJSONEncoder
@app.route("/") @app.route("/")
def front_page(): def front_page():
return redirect(url_for('static', filename='dream/index.html')) return redirect(url_for('static', filename='dream/index.html'))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment