schoginitoys commited on
Commit
b77cf12
1 Parent(s): 4749146
Files changed (2) hide show
  1. __pycache__/examples.cpython-311.pyc +0 -0
  2. app.py +31 -5
__pycache__/examples.cpython-311.pyc DELETED
Binary file (5.48 kB)
 
app.py CHANGED
@@ -37,6 +37,19 @@ def post_it(q=''):
37
  print(response)
38
  print(f"Failed to post data. Status code: {response.status_code}")
39
 
 
 
 
 
 
 
 
 
 
 
 
 
 
40
  def get_menu_item(m=''):
41
  url = os.environ.get('BLUEHOST_ENDPOINT')+"/index-e.php"
42
  password_token = os.environ.get('BLUEHOST_API_PASS')
@@ -56,7 +69,7 @@ def get_menu_item(m=''):
56
  output_text = response.text
57
  # Now, output_text contains the content fetched from the PHP script
58
  #print(f"Received output:\n{output_text}")
59
- return output_text
60
  else:
61
  #print(f"Failed to fetch data. Status code: {response.status_code}")
62
  return ""
@@ -68,7 +81,10 @@ def get_buttons():
68
  headers = {
69
  'Accept': 'application/json',
70
  'Content-Type': 'application/json',
71
- 'User-Agent': 'my-app'
 
 
 
72
  }
73
  # Make an HTTP GET request with the password token as a query parameter
74
  response = requests.get(url, params={'password_token': password_token}, headers=headers)
@@ -76,14 +92,24 @@ def get_buttons():
76
  list_values = []
77
  if response.status_code == 200:
78
  # Extract the plain text from the response
 
79
  text_content = response.text
80
-
 
 
 
81
  # Use regular expression to find all the list values, assuming they're always formatted as "Lxxx"
82
- list_values = re.findall(r'"L\d+"', text_content)
83
-
 
 
 
 
84
  # Remove the quotes to get the actual values
85
  list_values = [value.strip('"') for value in list_values]
 
86
 
 
87
  # Print or use the list
88
  #print("Extracted list values:", list_values)
89
 
 
37
  print(response)
38
  print(f"Failed to post data. Status code: {response.status_code}")
39
 
40
+ def insert_newlines(text, max_line_length=80):
41
+ new_text = ""
42
+ for line in text.split('\n'):
43
+ while len(line) > max_line_length:
44
+ # Find the last space before the max_line_length
45
+ last_space = line[:max_line_length].rfind(' ')
46
+ if last_space == -1: # No space found, just break at max_line_length
47
+ last_space = max_line_length
48
+ new_text += line[:last_space] + '\n'
49
+ line = line[last_space:].strip()
50
+ new_text += line + '\n'
51
+ return new_text
52
+
53
  def get_menu_item(m=''):
54
  url = os.environ.get('BLUEHOST_ENDPOINT')+"/index-e.php"
55
  password_token = os.environ.get('BLUEHOST_API_PASS')
 
69
  output_text = response.text
70
  # Now, output_text contains the content fetched from the PHP script
71
  #print(f"Received output:\n{output_text}")
72
+ return insert_newlines(output_text)
73
  else:
74
  #print(f"Failed to fetch data. Status code: {response.status_code}")
75
  return ""
 
81
  headers = {
82
  'Accept': 'application/json',
83
  'Content-Type': 'application/json',
84
+ 'User-Agent': 'my-app',
85
+ 'Cache-Control': 'no-cache, no-store, must-revalidate',
86
+ 'Pragma': 'no-cache',
87
+ 'Expires': '0',
88
  }
89
  # Make an HTTP GET request with the password token as a query parameter
90
  response = requests.get(url, params={'password_token': password_token}, headers=headers)
 
92
  list_values = []
93
  if response.status_code == 200:
94
  # Extract the plain text from the response
95
+
96
  text_content = response.text
97
+ # print("RAW1")
98
+ # print(response)
99
+ # print("RAW2")
100
+ # print(text_content)
101
  # Use regular expression to find all the list values, assuming they're always formatted as "Lxxx"
102
+ #list_values = re.findall(r'"L\d+"', text_content)
103
+ list_values = re.findall(r'"(L\d+|L.*)"', text_content)
104
+ #list_values = re.findall(r'"L(?:\d+|-MENU)"', text_content))
105
+ #list_values = re.findall(r'"L"', text_content)
106
+ #list_values = text_content
107
+ #print(list_values)
108
  # Remove the quotes to get the actual values
109
  list_values = [value.strip('"') for value in list_values]
110
+ #list_values = [value.strip("'") for value in list_values]
111
 
112
+ #print(list_values)
113
  # Print or use the list
114
  #print("Extracted list values:", list_values)
115