Skip to content

Commit

Permalink
Patch
Browse files Browse the repository at this point in the history
Update function: Update_Virtual_Table()
ATMT: change google to Bing
Added dev database
Disable thread check in database loader
Better search result
remove unused import in search code
  • Loading branch information
EndermanPC committed Feb 11, 2024
1 parent e1fb0cf commit 67b8765
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 25 deletions.
6 changes: 5 additions & 1 deletion adpn.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from log.write import sys_log
from account.loader import account_database_loader
from account.reliability import get_user_reliability
from main import MainForm

print('Welcome to Neutron Administrator Panel')

Expand Down Expand Up @@ -122,7 +123,9 @@ def change_reliability_by_user_id(user_id, new_reliability):
if (yn != 'n'):
Initializer_Database()
Initializer_Virtual_Table()
Update_Virtual_Table()
vt_conn = database_loader()
Update_Virtual_Table(vt_conn)
vt_conn.close()
subprocess.call("start server1", shell=True)
subprocess.call("start server2", shell=True)
print('The server has been started successfully.')
Expand All @@ -138,6 +141,7 @@ def change_reliability_by_user_id(user_id, new_reliability):
elif command == "sync-fts":
vt_conn = database_loader()
Update_Virtual_Table(vt_conn)
vt_conn.close()
print("Successful data synchronization.")
elif command == "log":
with open('log.txt', 'r') as file:
Expand Down
4 changes: 2 additions & 2 deletions atmt.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def get_website_info(url):
title = soup.title.string.strip()

text_content = ''
for paragraph in soup.find_all(['p', 'div']):
for paragraph in soup.find_all(['p']):
text_content += paragraph.get_text().strip() + '\n'

meta_description = soup.find('meta', attrs={'name': 'description'})
Expand All @@ -45,7 +45,7 @@ def ATMT_STRT(random_keyword):
conn = database_loader()
user_agent = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/107 Safari/537.36'
headers = {'User-Agent': user_agent}
search_url = f"https://www.google.com/search?q={random_keyword}&hl=en"
search_url = f"https://www.bing.com/search?q={random_keyword}"

response = requests.get(search_url, headers=headers)

Expand Down
Binary file added database/censorship.db
Binary file not shown.
Binary file added database/search-index.db
Binary file not shown.
2 changes: 1 addition & 1 deletion initializer/loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from log.write import sys_log

def database_loader():
conn = sqlite3.connect('./database/search-index.db')
conn = sqlite3.connect('./database/search-index.db', check_same_thread=False)
sys_log("Loaded", "search-index.db")
return conn

Expand Down
29 changes: 9 additions & 20 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,79 +4,65 @@
from manager.manager import *
from search.index import Search_Data

conn = database_loader()
if 'conn' not in st.session_state:
st.session_state.conn = database_loader()
conn = st.session_state.conn

st.title('Neutron')

st.session_state.setdefault('form_state', True)

Search_Result = []

with st.form('Input_Form'):
col1, col2, col3, col4, col5 = st.columns([3, 0.8, 0.6, 0.6, 0.8])
AForm = st.session_state.form_state

with col1:
keyword = st.text_input('Try to search something!', placeholder='Try to search something!', label_visibility='collapsed')

with col2:
submitted1 = st.form_submit_button('Search')

with col3:
submitted2 = st.form_submit_button('Add')

with col4:
submitted3 = st.form_submit_button('Edit')

with col5:
submitted4 = st.form_submit_button('Remove')

if keyword and submitted1:
Search_Result = Search_Data(conn, keyword)

if submitted2 and AForm == True:
username = st.text_input('Username: ')
password = st.text_input('Password: ', type='password')

link = st.text_input('Link (Should not contain a "/" at the end, use only "http" and "https"): ')
title = st.text_input('Title: ')
text = st.text_input('Text: ')
description = st.text_input('Description: ')
keywords = st.text_input('Keywords: ')
shorttext = st.text_input('Short Text: ')

if username and password and link and title and text and description and keywords and shorttext:
with st.spinner('Checking the given information...'):
time.sleep(1)
manager_insert_data(conn, username, password, link, title, text, description, keywords, shorttext)
st.session_state.add_state = False
elif submitted2 and not AForm:
st.session_state.add_state = True

if submitted3 and AForm == True:
username = st.text_input('Username: ')
password = st.text_input('Password: ', type='password')

site_id = st.text_input('Site ID: ')
link = st.text_input('Link (Should not contain a "/" at the end, use only "http" and "https"): ')
title = st.text_input('Title: ')
text = st.text_input('Text: ')
description = st.text_input('Description: ')
keywords = st.text_input('Keywords: ')
shorttext = st.text_input('Short Text: ')

if username and password and site_id and link and title and text and description and keywords and shorttext:
with st.spinner('Checking the given information...'):
time.sleep(1)
manager_edit_data(conn, username, password, site_id, link, title, text, description, keywords, shorttext)
st.session_state.add_state = False
elif submitted3 and not AForm:
st.session_state.add_state = True

if submitted4 and AForm == True:
username = st.text_input('Username: ')
password = st.text_input('Password: ', type='password')

site_id = st.text_input('Site ID: ')

if username and password and site_id:
Expand All @@ -86,9 +72,12 @@
st.session_state.add_state = False
elif submitted4 and not AForm:
st.session_state.add_state = True

for row in Search_Result:
st.markdown('```' + str(row[0]) + '``` ```' + row[1] + '```')
st.markdown("### [" + row[2] + ']' + '(' + row[1] + ')')
st.write(row[6])
row_title = row[2].replace('\n', ' ')
row_title = row_title.replace(':', ' ')
st.markdown("### [" + row_title + ']' + '(' + row[1] + ')')
row_shorttext = row[6].replace('\n', ' ')
row_shorttext = row_shorttext.replace('```', ' ')
st.markdown("```" + row_shorttext + "```")
st.markdown("   ")
1 change: 0 additions & 1 deletion search/index.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import pandas as pd
import streamlit as st

from atmt import ATMT_STRT
Expand Down

0 comments on commit 67b8765

Please sign in to comment.