forked from VishnuDileesh/NewsScrape
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.py
36 lines (24 loc) · 880 Bytes
/
app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
from newspaper import Article
from bs4 import BeautifulSoup
import requests
from flask import Flask, render_template, redirect
from flask_sqlalchemy import SQLAlchemy
import os
project_dir = os.path.dirname(os.path.abspath(__file__))
database_file = "sqlite:///{}".format(os.path.join(project_dir, "news_scrape.db"))
app = Flask(__name__)
app.config["SQLALCHEMY_DATABASE_URI"] = database_file
app.config["SQLALCHEMY_TRACK_MODIFICATIONS"] = False
app.config["SECRET_KEY"] = "newisthesecretofsecretscrape"
db = SQLAlchemy(app)
class Articlelist(db.Model):
id = db.Column(db.Integer, primary_key=True)
title = db.Column(db.Text)
author = db.Column(db.Text)
summary = db.Column(db.Text)
@app.route('/')
def index():
articles = Articlelist.query.all()
return render_template("index.html", articles=articles)
if __name__ == "__main__":
app.run()