File tree Expand file tree Collapse file tree 1 file changed +41
-0
lines changed
Expand file tree Collapse file tree 1 file changed +41
-0
lines changed Original file line number Diff line number Diff line change 1+ import wifi
2+ wifi .try_connect ()
3+
4+ # 返回数据response header
5+ headers = {'Access-Control-Allow-Origin' : '*' }
6+
7+ from microbit import *
8+ from microWebSrv import MicroWebSrv
9+
10+ @MicroWebSrv .route ('/get_temp' )
11+ def _httpHandlerTestGet (httpClient , httpResponse ):
12+ params = httpClient .GetRequestQueryParams ()
13+ tmp = temperature () # get temperature ℃
14+ obj = {
15+ 'temperature' : str (tmp ),
16+ }
17+ httpResponse .WriteResponseJSONOk (obj = obj , headers = headers )
18+
19+ @MicroWebSrv .route ('/SAD' )
20+ def _httpHandlerTestGet (httpClient , httpResponse ):
21+ params = httpClient .GetRequestQueryParams ()
22+ display .show (Image .SAD )
23+
24+ @MicroWebSrv .route ('/scroll' )
25+ def _httpHandlerTestGet (httpClient , httpResponse ):
26+ params = httpClient .GetRequestQueryParams ()
27+ display .scroll (str (params ['text' ]))
28+
29+ if __name__ == '__main__' :
30+ if 'srv' in locals ():
31+ reset ()
32+ pin13 .write_digital (0 )
33+ import time
34+ while True :
35+ time .sleep (2 )
36+ if wifi .isconnected ():
37+ srv = MicroWebSrv (webPath = 'www/' )
38+ srv .Start (True )
39+ pin13 .write_digital (1 )
40+ else :
41+ pin13 .write_digital (0 )
You can’t perform that action at this time.
0 commit comments