File size: 3,490 Bytes
5f07f11
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
import streamlit as st
import requests
from dotenv import load_dotenv
import os
import time
from helper.telemetry import collect_telemetry
from helper.upload_File import uploadFile
from helper.button_behaviour import hide_button, unhide_button
from helper.initialize_analyze_session import initialize_analyze_session
import pandas as pd

class Content:
    def __init__(self, model_url):
        self.uploaded_files = []
        self.file_dict = {}
        self.file_gt = {}
        self.model_url = model_url
        #self.analyst_name = analyst_name
        #self.data_src = data_src
        #self.analyst_description = analyst_description
        self.initialize()
        
        self.row1()

    def initialize(self):
        # FOR ENV
        load_dotenv()

        if 'content_in_the_website' not in st.session_state:
            st.session_state['content_in_the_website'] = ''
        if 'content_outside_the_website' not in st.session_state:
            st.session_state['content_outside_the_website'] = ''
    
    def process(self):
                session = st.session_state.analyze

                if (self.content_in_the_website or self.content_outside_the_website) and session == 'clicked':
                    with st.spinner('SEO On Page Analyst...', show_time=True):
                        st.write('')
                        content_in_the_website = ""
                        content_outside_the_website = ""
                        try:
                            content_in_the_website += f"\nContent in the Website: {self.content_in_the_website}"
                        except KeyError:
                            pass
                        try:
                            content_outside_the_website += f"\nContent outside the Website: {self.content_outside_the_website}"
                        except KeyError:
                            pass

                        debug_info_content_in_the_website = {'data_field' : 'Content in the Website', 'result': content_in_the_website}
                        debug_info_content_outside_the_website = {'data_field' : 'Content outside the Website', 'result': content_outside_the_website}

                        if self.content_in_the_website:
                            st.session_state['content_in_the_website'] = 'uploaded'
                            collect_telemetry(debug_info_content_in_the_website)
                        if self.content_outside_the_website:
                            st.session_state['content_outside_the_website'] = 'uploaded'
                            collect_telemetry(debug_info_content_outside_the_website)
                        
                            
                        #with st.expander("Debug information", icon="⚙"):
                        #    st.write(debug_info)


                        st.session_state['analyzing'] = False
                        try:
                            self.file_dict.popitem()
                        except KeyError:
                            pass
                        
    def row1(self):
            self.content_in_the_website = st.text_input("Content in the Website (Website Content)", placeholder='Enter Content in the Website')
            self.content_outside_the_website = st.text_input("Content outside the Website (Website Content)", placeholder='Enter Content outside the Website')

            self.process()

if __name__ == "__main__":
    st.set_page_config(layout="wide")

upload = uploadFile()