I need to define my own variables that would be saved on server while it's running. I am trying to use `flask.g` but it throws an error: 

```
AttributeError: '_AppCtxGlobals' object has no attribute 'x'

```

Here is the code:

```
from flask import *
app=Flask(__name__)
@app.route('/')
def opa():
    #Added this to define variable
    try:
        g.x
    except NameError:
        g.x=None
    #Added this to add value to variable
    if g.x is None:
        g.x='Already defined'
        return 'x is now defined'
    else:
        return g.x
if __name__ == "__main__":
    app.run(host='0.0.0.0',port=8081,debug=True)

```