I have a problem with global variable. It returns error
search = Search.Search(pattern,b)
NameError: global name 'b' is not defined
But I have already defined this global variable. I tried to put it even into the search function. I think that there was no problem with that on Windows. I'm trying to run this program on Linux/Unix.
Do you have any advice how to avoid this error?
# -*- coding: utf-8 -*-
from flask import Flask
from flask import request
from flask import render_template
import Search
import B
app = Flask(__name__)
global b
@app.route('/')
def my_form():
return render_template('my-form.html')
def setup():
global b
b = B.B()
@app.route('/', methods=['POST'])
def search():
global b
from time import time
pattern = request.form['text']
...
se = Search.Search(pattern,b)
...
...
...
app.debug=True
if __name__ == '__main__':
setup()
app.run()