schoginitoys
commited on
Commit
•
bf9c842
1
Parent(s):
b77cf12
Sree
Browse files
app.py
CHANGED
@@ -7,7 +7,35 @@ import time
|
|
7 |
#import examples
|
8 |
import os
|
9 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
10 |
|
|
|
11 |
|
12 |
def post_it(q=''):
|
13 |
# Define the URL and parameters
|
@@ -23,7 +51,7 @@ def post_it(q=''):
|
|
23 |
'Content-Type': 'application/json',
|
24 |
'User-Agent': 'my-app'
|
25 |
}
|
26 |
-
print(url)
|
27 |
# Make the POST request
|
28 |
# response = requests.post(url, params=params)
|
29 |
response = requests.get(url, params=params, headers=headers)
|
@@ -34,7 +62,7 @@ def post_it(q=''):
|
|
34 |
#print("Response:", response.text)
|
35 |
pass
|
36 |
else:
|
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):
|
@@ -56,7 +84,10 @@ def get_menu_item(m=''):
|
|
56 |
headers = {
|
57 |
'Accept': 'application/json',
|
58 |
'Content-Type': 'application/json',
|
59 |
-
'User-Agent': 'my-app'
|
|
|
|
|
|
|
60 |
}
|
61 |
params = {
|
62 |
'password_token': password_token,
|
@@ -161,13 +192,21 @@ def greet(name):
|
|
161 |
msg="Please click any button below or enter your query."
|
162 |
else:
|
163 |
menu_code = get_menu_item(name)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
164 |
if menu_code =='':
|
165 |
try:
|
166 |
tpl=eval("examples." + name)
|
167 |
print("examples." + name)
|
168 |
msg = "```python\n" + tpl + "\n```\n"
|
169 |
except:
|
170 |
-
tpl=
|
171 |
post_it(name) # Save the query in bluehost
|
172 |
msg = tpl
|
173 |
else:
|
|
|
7 |
#import examples
|
8 |
import os
|
9 |
|
10 |
+
THANKS = """
|
11 |
+
|
12 |
+
# THANKS FOR YOUR QUERY
|
13 |
+
|
14 |
+
### You have two more options to get AI assistance
|
15 |
+
|
16 |
+
### 1) Use ChatGPT with the below prompt
|
17 |
+
#### === MicroPython Script Guidelines ===
|
18 |
+
#### - Import: Use 'from schoginitoys import *'
|
19 |
+
#### - Joystick: Use Config.xValue, Config.yValue, Config.up, Config.down, Config.right, Config.left, Config.button_pressed
|
20 |
+
#### - Buzzer: Use beep() for 0.1s beep, beep(2) for 2s beep
|
21 |
+
#### - Display: Use show("text"), scroll("text"), display_bitmap(bitmap_data, col), display.set_pixel(col, row, value)
|
22 |
+
#### - Exit: Use Config.left or Config.button_pressed to exit
|
23 |
+
#### - Libraries: No need to import random, time, urandom, string; we handle it
|
24 |
+
#### - Output: Use show() for strings <= 4 chars, scroll() for longer strings
|
25 |
+
#### - Reset: No need to call display_reset(); it's handled in our library
|
26 |
+
#### - Formatting: Ensure all code is formatted
|
27 |
+
#### - Explanations: Include kid-friendly explanations below each code snippet
|
28 |
+
#### - Hyperlinks: Add a link to https://schoginitoys.com for more info
|
29 |
+
#### - LED Specs: 32 columns x 8 rows; use display.show() after display.set_pixel()
|
30 |
+
- LED Connections: GP12=Red, GP13=Yellow, GP14=Green; use these for LED-based projects
|
31 |
+
- Ask your question here.
|
32 |
+
|
33 |
+
### 2) Register at https://schoginitoys.com/p01 to gain access to
|
34 |
+
### our AI Chatbot: Coding Assistance
|
35 |
+
|
36 |
+
## Schogini Toys Tech Team!
|
37 |
|
38 |
+
"""
|
39 |
|
40 |
def post_it(q=''):
|
41 |
# Define the URL and parameters
|
|
|
51 |
'Content-Type': 'application/json',
|
52 |
'User-Agent': 'my-app'
|
53 |
}
|
54 |
+
# print(url)
|
55 |
# Make the POST request
|
56 |
# response = requests.post(url, params=params)
|
57 |
response = requests.get(url, params=params, headers=headers)
|
|
|
62 |
#print("Response:", response.text)
|
63 |
pass
|
64 |
else:
|
65 |
+
#print(response)
|
66 |
print(f"Failed to post data. Status code: {response.status_code}")
|
67 |
|
68 |
def insert_newlines(text, max_line_length=80):
|
|
|
84 |
headers = {
|
85 |
'Accept': 'application/json',
|
86 |
'Content-Type': 'application/json',
|
87 |
+
'User-Agent': 'my-app',
|
88 |
+
'Cache-Control': 'no-cache, no-store, must-revalidate',
|
89 |
+
'Pragma': 'no-cache',
|
90 |
+
'Expires': '0',
|
91 |
}
|
92 |
params = {
|
93 |
'password_token': password_token,
|
|
|
192 |
msg="Please click any button below or enter your query."
|
193 |
else:
|
194 |
menu_code = get_menu_item(name)
|
195 |
+
#print("menu_code: " + menu_code)
|
196 |
+
# if "not found" in menu_code:
|
197 |
+
if re.search(r"not found", menu_code):
|
198 |
+
tpl=THANKS #examples.PROJECT_TEMPLATE
|
199 |
+
post_it(name) # Save the query in bluehost
|
200 |
+
msg = tpl
|
201 |
+
#menu_code = tpl
|
202 |
+
return msg
|
203 |
if menu_code =='':
|
204 |
try:
|
205 |
tpl=eval("examples." + name)
|
206 |
print("examples." + name)
|
207 |
msg = "```python\n" + tpl + "\n```\n"
|
208 |
except:
|
209 |
+
tpl=THANKS #PROJECT_TEMPLATE
|
210 |
post_it(name) # Save the query in bluehost
|
211 |
msg = tpl
|
212 |
else:
|