acecalisto3 commited on
Commit
7f6785e
·
verified ·
1 Parent(s): 689bacc

Update app2.py

Browse files
Files changed (1) hide show
  1. app2.py +15 -23
app2.py CHANGED
@@ -1,21 +1,27 @@
1
  import asyncio
2
  import csv
3
- import logging
4
- import os
5
- from typing import List, Tuple
6
-
7
- import aiohttp
8
- import datetime
9
  import hashlib
 
 
10
 
11
  import feedparser
12
  import gradio as gr
13
  from huggingface_hub import InferenceClient
14
  from sqlalchemy import create_engine, Column, Integer, String, Text, DateTime
15
- from sqlalchemy.orm import declarative_base, sessionmaker
16
  from sqlalchemy.exc import SQLAlchemyError
17
- import validators
18
- from bs4 import BeautifulSoup
 
 
 
 
 
 
 
 
 
 
 
19
 
20
  # Configure logging
21
  logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
@@ -33,20 +39,6 @@ url_monitoring_intervals = {}
33
  change_counts = {}
34
  history = []
35
 
36
- # Database setup
37
- Base = declarative_base()
38
-
39
-
40
- class Article(Base):
41
- __tablename__ = 'articles'
42
- id = Column(Integer, primary_key=True)
43
- url = Column(String(255), nullable=False)
44
- title = Column(String(255))
45
- content = Column(Text)
46
- hash = Column(String(32))
47
- timestamp = Column(DateTime, default=datetime.datetime.utcnow)
48
-
49
-
50
  async def create_db_engine(db_url):
51
  try:
52
  engine = create_engine(db_url)
 
1
  import asyncio
2
  import csv
 
 
 
 
 
 
3
  import hashlib
4
+ import os
5
+ from typing import List, Tuple, Dict, Any, Optional
6
 
7
  import feedparser
8
  import gradio as gr
9
  from huggingface_hub import InferenceClient
10
  from sqlalchemy import create_engine, Column, Integer, String, Text, DateTime
 
11
  from sqlalchemy.exc import SQLAlchemyError
12
+ from sqlalchemy.orm import declarative_base, sessionmaker
13
+ from urllib.parse import urljoin
14
+
15
+ Base = declarative_base()
16
+
17
+ class Article(Base):
18
+ __tablename__ = 'articles'
19
+ id = Column(Integer, primary_key=True)
20
+ url = Column('url', String(2048), nullable=False, unique=True) # Increased URL length limit
21
+ title = Column('title', String(255))
22
+ content = Column('content', Text())
23
+ hash_value = Column('hash', String(32))
24
+ timestamp = Column('timestamp', DateTime(), default=datetime.datetime.utcnow)
25
 
26
  # Configure logging
27
  logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
 
39
  change_counts = {}
40
  history = []
41
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
42
  async def create_db_engine(db_url):
43
  try:
44
  engine = create_engine(db_url)