Hello,
I want to know why it does not access the def login and I have seen that with import logging you can create a file and show the debugs that you have been putting in your code.
Something like that:
The issue is how do I know if it’s entering the def, and if it doesn’t (my case), what error is it leaving.
Locally it works for me but not on the hosting server, the fact is that I need to have records to know where it is failing.
Have a small main module that imports all the rest of the code and runs it.
Wrap all that code, including the imports, in a try except block that will log any exception that is raised using the exception method of the logging module.
I understand, but one thing, and I’m sorry I don’t understand much of this, does the part of the code that you show have to go inside my application startup file app.py?
Hello, I mean how should I build the file.
For example: I have a file app.py where I have all the code and for example the def login() which is the initial one.
@app.route('/login', methods=['GET', 'POST'])
def login():
if request.method=='POST':
logging.debug(request.form['username'])
user = User(0,request.form['username'],request.form['password'])
logging.debug(user)
logged_user=ModelUser.login(db,user)
if logged_user != None:
if logged_user.password:
login_user(logged_user)
return redirect(url_for('home'))
else:
flash("invalid password")
return render_template('auth/login.html')
else:
flash("User not found")
return render_template('auth/login.html')
else:
return render_template('auth/login.html')
I cannot know as you are only showing us some of your application.
What is the full set of all files you currently have?
How do you run your application?
Note I used app as a place holder for what ever your application file name was.
in local if I create the log file
I execute as indicated in python main.py but when I upload the new file app.py and the main.py to the hosting, it does not generate any log
In my hosting I also have an app.wsgi file with the code
import sys
sys.path.insert(0, '/var/www/html/flask_project')
from app import main as application
this code makes link with app.py
Should I modify that line to from app import main as application or something similar?
I understand.
It is a very curious thing that happens to me with two similar applications and in two different hostings, the server has something in part of the code that it does not like, although locally it is correct and functional.