diff --git a/wsgi.py b/wsgi.py index cc00218..2e03977 100644 --- a/wsgi.py +++ b/wsgi.py @@ -2,8 +2,37 @@ Point d'entrée Gunicorn pour la production. Usage : gunicorn -c gunicorn.conf.py wsgi:app """ -from app import app, _init_db, start_scheduler +from app import app, db, _init_db, start_scheduler +from app import CrawlSource + +_DEFAULT_SOURCES = [ + ('HAS', 'https://www.has-sante.fr/', 'webpage', 'scientific'), + ('Ameli', 'https://www.ameli.fr/', 'index', 'advice'), + ('Sante publique France', 'https://www.santepubliquefrance.fr/', 'index', 'advice'), + ('Top sante', 'https://www.topsante.com/', 'index', 'advice'), + ('Examine.com - Supplements', 'https://examine.com/supplements/', 'index', 'scientific'), + ('Examine.com - Nutrition', 'https://examine.com/nutrition/', 'index', 'scientific'), + ('NutritionFacts.org', 'https://nutritionfacts.org/feed/', 'rss', 'advice'), + ('Harvard Health Blog', 'https://www.health.harvard.edu/blog/feed', 'rss', 'advice'), + ('ScienceDaily - Sante', 'https://www.sciencedaily.com/rss/health_medicine.xml', 'rss', 'advice'), + ('Medical News Today', 'https://www.medicalnewstoday.com/rss', 'rss', 'advice'), + ('NEJM - Current Issue', 'https://www.nejm.org/action/showFeed?jc=nejm&type=etoc&feed=rss', 'rss', 'scientific'), + ('BMJ - Current Issue', 'https://www.bmj.com/rss/thebmj.xml', 'rss', 'scientific'), + ('The Lancet', 'https://www.thelancet.com/rssfeed/lancet_current.xml', 'rss', 'scientific'), + ('PubMed - Nutrition', 'https://pubmed.ncbi.nlm.nih.gov/rss/search/0f8VGqGLrpuLRhtqFbgA5gf7wSDBrw_V/?limit=20&format=abstract', 'rss', 'scientific'), +] + + +def _seed_sources(): + """Insert default sources if the table is empty.""" + if CrawlSource.query.count() > 0: + return + for name, url, stype, cat in _DEFAULT_SOURCES: + db.session.add(CrawlSource(name=name, url=url, source_type=stype, category=cat)) + db.session.commit() + with app.app_context(): _init_db() + _seed_sources() start_scheduler()