I am from Java world and new to python and so to Flask. Here is my views.py
from app import app
class Employee:
def __init__(id,name): self.id = id; self.name = name;
@app.route('/')
@app.route('/index')
def index():
return Employee(12345,"MyName")
In the function index(), when i tried to return "Hello World" without class Employee in the file and run the server, Hello World string was written to the webpage.
I then thought of outputting a json,
{"id":"12345","name":"MyName"}
So I started to introduce a class Employee and created a constructor to pass id and name.
Unfortunately it started showing this error.
File "C:\python\microblog\app\views.py", line 9, in index return Employee(12345,"MyName")
By the way, here i assume that if I can get rid of the error, flask would be able to convert the object to json by taking it as default mimetype for objects.
I had look at these answers, but didn't help with my knowledge.