Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -20,31 +20,16 @@ sources = {
|
|
| 20 |
"Intelligence.gov": "https://www.intelligence.gov/",
|
| 21 |
"DIA Archives": "https://www.dia.mil/FOIA/",
|
| 22 |
"EPA FOIA": "https://www.epa.gov/foia",
|
| 23 |
-
"NASA FOIA": "https://www.nasa.gov/foia",
|
|
|
|
| 24 |
"FCC FOIA": "https://www.fcc.gov/general/foia-request-guide",
|
| 25 |
"Department of the Interior FOIA": "https://www.doi.gov/foia",
|
| 26 |
"National Archives Electronic Reading Room": "https://www.archives.gov/foia/electronic-reading-room",
|
| 27 |
"NGA FOIA": "https://www.nga.mil/resources/foia.html",
|
| 28 |
"DARPA FOIA": "https://www.darpa.mil/about-us/foia",
|
| 29 |
-
|
| 30 |
-
"DEA FOIA": "https://www.dea.gov/foia",
|
| 31 |
-
"USSS FOIA": "https://www.secretservice.gov/contact/foia",
|
| 32 |
-
"ODNI FOIA": "https://www.dni.gov/index.php/about-this-site/foia",
|
| 33 |
-
"FEMA FOIA": "https://www.fema.gov/foia",
|
| 34 |
-
|
| 35 |
-
# International Archives
|
| 36 |
-
"UK National Archives": "https://www.nationalarchives.gov.uk/",
|
| 37 |
-
"Canadian Government Archives": "https://www.bac-lac.gc.ca/eng/pages/home.aspx",
|
| 38 |
-
"Australian Government Archives": "https://www.naa.gov.au/",
|
| 39 |
-
"German Federal Archives ": "https://www.bundesarchiv.de/en/home/home.html",
|
| 40 |
-
"French National Archives ": "https:/ / www.archives-nationales.culture.gouv.fr/en/home",
|
| 41 |
}
|
| 42 |
|
| 43 |
-
# Historical Document Collections
|
| 44 |
-
b
|
| 45 |
-
b
|
| 46 |
-
b
|
| 47 |
-
|
| 48 |
# Async function to fetch data
|
| 49 |
async def fetch_data(url):
|
| 50 |
async with aiohttp.ClientSession() as session:
|
|
@@ -66,4 +51,32 @@ def display_sources():
|
|
| 66 |
loop = asyncio.get_event_loop()
|
| 67 |
results = loop.run_until_complete(fetch_all_sources(sources))
|
| 68 |
|
| 69 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
"Intelligence.gov": "https://www.intelligence.gov/",
|
| 21 |
"DIA Archives": "https://www.dia.mil/FOIA/",
|
| 22 |
"EPA FOIA": "https://www.epa.gov/foia",
|
| 23 |
+
"NASA FOIA": "https://www.nasa.gov/foia",
|
| 24 |
+
"NOAA FOIA": "https://www.noaa.gov/foia",
|
| 25 |
"FCC FOIA": "https://www.fcc.gov/general/foia-request-guide",
|
| 26 |
"Department of the Interior FOIA": "https://www.doi.gov/foia",
|
| 27 |
"National Archives Electronic Reading Room": "https://www.archives.gov/foia/electronic-reading-room",
|
| 28 |
"NGA FOIA": "https://www.nga.mil/resources/foia.html",
|
| 29 |
"DARPA FOIA": "https://www.darpa.mil/about-us/foia",
|
| 30 |
+
# Add more sources as needed
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 31 |
}
|
| 32 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 33 |
# Async function to fetch data
|
| 34 |
async def fetch_data(url):
|
| 35 |
async with aiohttp.ClientSession() as session:
|
|
|
|
| 51 |
loop = asyncio.get_event_loop()
|
| 52 |
results = loop.run_until_complete(fetch_all_sources(sources))
|
| 53 |
|
| 54 |
+
store_data(results)
|
| 55 |
+
|
| 56 |
+
return results
|
| 57 |
+
|
| 58 |
+
# Database setup
|
| 59 |
+
engine = create_engine('sqlite:///foia_archive.db')
|
| 60 |
+
Base = declarative_base()
|
| 61 |
+
|
| 62 |
+
class Document(Base):
|
| 63 |
+
__tablename__ = 'documents'
|
| 64 |
+
id = Column(Integer, primary_key=True)
|
| 65 |
+
source = Column(String)
|
| 66 |
+
content = Column(String)
|
| 67 |
+
|
| 68 |
+
Base.metadata.create_all(engine)
|
| 69 |
+
|
| 70 |
+
def store_data(data):
|
| 71 |
+
Session = sessionmaker(bind=engine)
|
| 72 |
+
session = Session()
|
| 73 |
+
|
| 74 |
+
for source, content in data.items():
|
| 75 |
+
doc = Document(source=source, content=content)
|
| 76 |
+
session.add(doc)
|
| 77 |
+
|
| 78 |
+
session.commit()
|
| 79 |
+
|
| 80 |
+
# Gradio interface
|
| 81 |
+
app = gr.Interface(fn=display_sources, inputs=[], outputs="json")
|
| 82 |
+
app.launch()
|