import json
import os
import tempfile


def store(data, directory="/var/www/luke/wikipedia/graphs/"):
    try:
        json.loads(data)
    except ValueError:
        return "not-json"

    tf = tempfile.mkstemp(prefix="", dir=directory)[1]

    with open(tf, "w") as f:
        f.write(data)
    return tf

if __name__ == "__main__":
    print(store('{}'))

import json
import os
import tempfile


def store(data, directory="/var/www/luke/wikipedia/graphs/"):
    try:
        json.loads(data)
    except ValueError:
        return "not-json"

    tf = tempfile.mkstemp(prefix="", dir=directory)[1]

    with open(tf, "w") as f:
        f.write(data)
    return os.path.split(tf)[1]

if __name__ == "__main__":
    print(store('{}'))

Tweak JSON api return value to be friendlier
Tweak JSON api return value to be friendlier
