7474# API v2 is defined in v2.yml and its methods are in api.py
7575connexionApp .add_api ('v2.yml' )
7676
77- # Serve (a build of) the new Vue application
78- # "dist" is the output of `npm run build` from the 'vue-app 'repository
79-
8077@app .route ('/vue/<path:filename>' )
8178def serve_vue_app (filename ):
79+ """
80+ Serve (a build of) the new Vue application
81+ "dist" is the output of `npm run build` from the 'vue-app 'repository
82+ """
8283 return send_from_directory ('dist' , filename )
8384
8485@app .route ('/' )
8586def redirect_vue_app ():
87+
8688 return redirect ('/vue/index.html' , code = 302 )
8789
8890## Legacy API and web application
8991
90- # Serve the legacy web application templates
9192@app .route ("/old" )
92- def handle_home ():
93+ def serve_legacy ():
94+ """
95+ Serve the the legacy web application
96+ """
9397 return render_template ('main.html' ,
9498 host = request .host [:request .host .find (':' )],
9599 locale = get_locale (),
@@ -132,32 +136,39 @@ def render_static_assets3(filename):
132136def render_static_assets4 (filename ):
133137 return send_from_directory ('static/media' , filename )
134138
135- """
136- Update the keys of oldDict appearing in updatedValues with the values in
137- updatedValues
138- """
139139def updateDict (oldDict , updatedValues ):
140+ """
141+ Update the keys of oldDict appearing in updatedValues with the values in
142+ updatedValues
143+ """
140144 result = oldDict
141145 for key , value in updatedValues .items ():
142146 result [key ] = value
143147 return result
144148
145- # Overwrite configuration file on disk and reload it
146149@app .route ("/config" , methods = ["POST" ])
147150def handle_config ():
151+ """
152+ Overwrite configuration file on disk and reload it
153+ """
148154 Config .write (updateDict (app .bot_config , request .form ))
149155 app .bot_config = Config .get ()
150156 return "ok"
151157
152- # Expose configuration as JSON
153158@app .route ("/config" , methods = ["GET" ])
154159def returnConfig ():
160+ """
161+ Expose configuration as JSON
162+ """
155163 app .bot_config = Config .get ()
156164 return (jsonify (app .bot_config ))
157165
158- # Changes wi-fi configuration and reboot
159166@app .route ("/wifi" , methods = ["POST" ])
160167def handle_wifi ():
168+ """
169+ Passes the received Wi-Fi configuration to the wifi.py script, applying it.
170+ Then reboots
171+ """
161172 mode = request .form .get ("wifi_mode" )
162173 ssid = request .form .get ("wifi_ssid" )
163174 psk = request .form .get ("wifi_psk" )
@@ -172,12 +183,6 @@ def handle_wifi():
172183 else :
173184 return "http://coderbot.local"
174185
175- # Update the system
176- @app .route ("/update" , methods = ["GET" ])
177- def handle_update ():
178- logging .info ("updating system.start" )
179- return Response (execute ("./scripts/update_coderbot.sh" ), mimetype = 'text/plain' )
180-
181186# Execute single command
182187@app .route ("/bot" , methods = ["GET" ])
183188def handle_bot ():
0 commit comments