I recently imported the LMS project from GitHub. The project is mainly created in Flask. I installed all the required modules and then trying to run the application. I seted the Flask to >>set FLASK_APP=run.py
. On flask_run
, it gives the following error. I'm not getting how to fix it. Looking forward for suggestions to resolve this error.
- Serving Flask app 'run' (lazy loading)
- Environment: production WARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead.
- Debug mode: off
Traceback (most recent call last):
File "c:\users\ali\appdata\local\programs\python\python38-32\lib\runpy.py", line 193, in _run_module_as_main
return _run_code(code, main_globals, None,
File "c:\users\ali\appdata\local\programs\python\python38-32\lib\runpy.py", line 86, in _run_code
exec(code, run_globals)
File "C:\Users\Ali\AppData\Local\Programs\Python\Python38-32\Scripts\flask.exe\__main__.py", line 7, in <module>
File "c:\users\ali\appdata\local\programs\python\python38-32\lib\site-packages\flask\cli.py", line 990, in main
cli.main(args=sys.argv[1:])
File "c:\users\ali\appdata\local\programs\python\python38-32\lib\site-packages\flask\cli.py", line 596, in main
return super().main(*args, **kwargs)
File "c:\users\ali\appdata\local\programs\python\python38-32\lib\site-packages\click\core.py", line 1062, in main
rv = self.invoke(ctx)
File "c:\users\ali\appdata\local\programs\python\python38-32\lib\site-packages\click\core.py", line 1668, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "c:\users\ali\appdata\local\programs\python\python38-32\lib\site-packages\click\core.py", line 1404, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "c:\users\ali\appdata\local\programs\python\python38-32\lib\site-packages\click\core.py", line 763, in invoke
return __callback(*args, **kwargs)
File "c:\users\ali\appdata\local\programs\python\python38-32\lib\site-packages\click\decorators.py", line 84, in new_func
return ctx.invoke(f, obj, *args, **kwargs)
File "c:\users\ali\appdata\local\programs\python\python38-32\lib\site-packages\click\core.py", line 763, in invoke
return __callback(*args, **kwargs)
File "c:\users\ali\appdata\local\programs\python\python38-32\lib\site-packages\flask\cli.py", line 845, in run_command
app = DispatchingApp(info.load_app, use_eager_loading=eager_loading)
File "c:\users\ali\appdata\local\programs\python\python38-32\lib\site-packages\flask\cli.py", line 321, in __init__
self._load_unlocked()
File "c:\users\ali\appdata\local\programs\python\python38-32\lib\site-packages\flask\cli.py", line 346, in _load_unlocked
self._app = rv = self.loader()
File "c:\users\ali\appdata\local\programs\python\python38-32\lib\site-packages\flask\cli.py", line 402, in load_app
app = locate_app(self, import_name, name)
File "c:\users\ali\appdata\local\programs\python\python38-32\lib\site-packages\flask\cli.py", line 256, in locate_app
__import__(module_name)
File "C:\Users\Ali\Documents\flask_app\run.py", line 19, in <module>
from application import app
File "C:\Users\Ali\Documents\flask_app\application\__init__.py", line 6, in <module>
import application.students
File "C:\Users\Ali\Documents\flask_app\application\students.py", line 9, in <module>
@validate_student
NameError: name 'validate_student' is not defined
C:\Users\Ali\Documents\flask_app>flask run
* Serving Flask app 'run' (lazy loading)
* Environment: production
WARNING: This is a development server. Do not use it in a production deployment.
Use a production WSGI server instead.
* Debug mode: off
Traceback (most recent call last):
File "c:\users\ali\appdata\local\programs\python\python38-32\lib\runpy.py", line 193, in _run_module_as_main
return _run_code(code, main_globals, None,
File "c:\users\ali\appdata\local\programs\python\python38-32\lib\runpy.py", line 86, in _run_code
exec(code, run_globals)
File "C:\Users\Ali\AppData\Local\Programs\Python\Python38-32\Scripts\flask.exe\__main__.py", line 7, in <module>
File "c:\users\ali\appdata\local\programs\python\python38-32\lib\site-packages\flask\cli.py", line 990, in main
cli.main(args=sys.argv[1:])
File "c:\users\ali\appdata\local\programs\python\python38-32\lib\site-packages\flask\cli.py", line 596, in main
return super().main(*args, **kwargs)
File "c:\users\ali\appdata\local\programs\python\python38-32\lib\site-packages\click\core.py", line 1062, in main
rv = self.invoke(ctx)
File "c:\users\ali\appdata\local\programs\python\python38-32\lib\site-packages\click\core.py", line 1668, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "c:\users\ali\appdata\local\programs\python\python38-32\lib\site-packages\click\core.py", line 1404, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "c:\users\ali\appdata\local\programs\python\python38-32\lib\site-packages\click\core.py", line 763, in invoke
return __callback(*args, **kwargs)
File "c:\users\ali\appdata\local\programs\python\python38-32\lib\site-packages\click\decorators.py", line 84, in new_func
return ctx.invoke(f, obj, *args, **kwargs)
File "c:\users\ali\appdata\local\programs\python\python38-32\lib\site-packages\click\core.py", line 763, in invoke
return __callback(*args, **kwargs)
File "c:\users\ali\appdata\local\programs\python\python38-32\lib\site-packages\flask\cli.py", line 845, in run_command
app = DispatchingApp(info.load_app, use_eager_loading=eager_loading)
File "c:\users\ali\appdata\local\programs\python\python38-32\lib\site-packages\flask\cli.py", line 321, in __init__
self._load_unlocked()
File "c:\users\ali\appdata\local\programs\python\python38-32\lib\site-packages\flask\cli.py", line 346, in _load_unlocked
self._app = rv = self.loader()
File "c:\users\ali\appdata\local\programs\python\python38-32\lib\site-packages\flask\cli.py", line 402, in load_app
app = locate_app(self, import_name, name)
File "c:\users\ali\appdata\local\programs\python\python38-32\lib\site-packages\flask\cli.py", line 256, in locate_app
__import__(module_name)
File "C:\Users\Ali\Documents\flask_app\run.py", line 19, in <module>
from application import app
File "C:\Users\Ali\Documents\flask_app\application\__init__.py", line 6, in <module>
import application.students
File "C:\Users\Ali\Documents\flask_app\application\students.py", line 9, in <module>
@validate_student
NameError: name 'validate_student' is not defined
C:\Users\Ali\Documents\flask_app>flask run
* Serving Flask app 'run' (lazy loading)
* Environment: production
WARNING: This is a development server. Do not use it in a production deployment.
Use a production WSGI server instead.
* Debug mode: off
Traceback (most recent call last):
File "c:\users\ali\appdata\local\programs\python\python38-32\lib\runpy.py", line 193, in _run_module_as_main
return _run_code(code, main_globals, None,
File "c:\users\ali\appdata\local\programs\python\python38-32\lib\runpy.py", line 86, in _run_code
exec(code, run_globals)
File "C:\Users\Ali\AppData\Local\Programs\Python\Python38-32\Scripts\flask.exe\__main__.py", line 7, in <module>
File "c:\users\ali\appdata\local\programs\python\python38-32\lib\site-packages\flask\cli.py", line 990, in main
cli.main(args=sys.argv[1:])
File "c:\users\ali\appdata\local\programs\python\python38-32\lib\site-packages\flask\cli.py", line 596, in main
return super().main(*args, **kwargs)
File "c:\users\ali\appdata\local\programs\python\python38-32\lib\site-packages\click\core.py", line 1062, in main
rv = self.invoke(ctx)
File "c:\users\ali\appdata\local\programs\python\python38-32\lib\site-packages\click\core.py", line 1668, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "c:\users\ali\appdata\local\programs\python\python38-32\lib\site-packages\click\core.py", line 1404, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "c:\users\ali\appdata\local\programs\python\python38-32\lib\site-packages\click\core.py", line 763, in invoke
return __callback(*args, **kwargs)
File "c:\users\ali\appdata\local\programs\python\python38-32\lib\site-packages\click\decorators.py", line 84, in new_func
return ctx.invoke(f, obj, *args, **kwargs)
File "c:\users\ali\appdata\local\programs\python\python38-32\lib\site-packages\click\core.py", line 763, in invoke
return __callback(*args, **kwargs)
File "c:\users\ali\appdata\local\programs\python\python38-32\lib\site-packages\flask\cli.py", line 845, in run_command
app = DispatchingApp(info.load_app, use_eager_loading=eager_loading)
File "c:\users\ali\appdata\local\programs\python\python38-32\lib\site-packages\flask\cli.py", line 321, in __init__
self._load_unlocked()
File "c:\users\ali\appdata\local\programs\python\python38-32\lib\site-packages\flask\cli.py", line 346, in _load_unlocked
self._app = rv = self.loader()
File "c:\users\ali\appdata\local\programs\python\python38-32\lib\site-packages\flask\cli.py", line 402, in load_app
app = locate_app(self, import_name, name)
File "c:\users\ali\appdata\local\programs\python\python38-32\lib\site-packages\flask\cli.py", line 256, in locate_app
__import__(module_name)
File "C:\Users\Ali\Documents\flask_app\run.py", line 19, in <module>
from application import app
File "C:\Users\Ali\Documents\flask_app\application\__init__.py", line 6, in <module>
import application.students
File "C:\Users\Ali\Documents\flask_app\application\students.py", line 7, in <module>
app = Flask(_validate_student_)
NameError: name '_validate_student_' is not defined
My Code Is:
from application import app
from flask import render_template, session, redirect, request, flash, escape
from functools import wraps
from flask import Flask
from helper_functions import *
app = Flask(_validate_student_)
@app.route('/students/')
@validate_student
def student_home():
return render_template('/students/index.html', classes=getStudentClasses())
@app.route('/students/classes/')
@validate_student
def student_classes_home():
return render_template('/students/classes.html', classes=getStudentClasses())
@app.route('/students/classes/join/', methods=['POST'])
@validate_student
def student_class_join():
insert_db("INSERT INTO roster (people_id, class_id) VALUES (?, ?);", [session['id'], request.form['id']])
flash("You joined the class with an id of %s" %(request.form['id']))
return redirect("/students/classes")