0
How to segregate python pages in flask and mysql?
I am beginner working on flask and mysql all my python code are in one single page in app.py but i no that this is not the correct way in flask and sqlalchamey they divide the pages into init.py, views.py, auth.py, main.py .writing python code in single page may leads to problem in loading pages.Is there any ways to divide py pages using flask and mysql. writing code in different python page try to import that pages in app.py ,worked on add_url_rule nothing is working.My project is little bit big so try to divide pages.
3 Respuestas
+ 2
Jayashree M
Listen,
In a Flask application with MySQL, you can segregate your Python code by using separate files for different components. This typically involves organizing code related to routes in app.py , database models in models.py , and route handlers in views.py .
+ 2
A͢J, Help This Man Because I Don't Know.
+ 1
Yes writing different routes in views.py is working but my every routes require database data after writing mysql details in views it shows me error , getting routes data from views and take blueprints is working but each routes requires mysql data,so i posted question here