74
74
# API v2 is defined in v2.yml and its methods are in api.py
75
75
connexionApp .add_api ('v2.yml' )
76
76
77
- # Serve (a build of) the new Vue application
78
- # "dist" is the output of `npm run build` from the 'vue-app 'repository
79
-
80
77
@app .route ('/vue/<path:filename>' )
81
78
def 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
+ """
82
83
return send_from_directory ('dist' , filename )
83
84
84
85
@app .route ('/' )
85
86
def redirect_vue_app ():
87
+
86
88
return redirect ('/vue/index.html' , code = 302 )
87
89
88
90
## Legacy API and web application
89
91
90
- # Serve the legacy web application templates
91
92
@app .route ("/old" )
92
- def handle_home ():
93
+ def serve_legacy ():
94
+ """
95
+ Serve the the legacy web application
96
+ """
93
97
return render_template ('main.html' ,
94
98
host = request .host [:request .host .find (':' )],
95
99
locale = get_locale (),
@@ -132,32 +136,39 @@ def render_static_assets3(filename):
132
136
def render_static_assets4 (filename ):
133
137
return send_from_directory ('static/media' , filename )
134
138
135
- """
136
- Update the keys of oldDict appearing in updatedValues with the values in
137
- updatedValues
138
- """
139
139
def updateDict (oldDict , updatedValues ):
140
+ """
141
+ Update the keys of oldDict appearing in updatedValues with the values in
142
+ updatedValues
143
+ """
140
144
result = oldDict
141
145
for key , value in updatedValues .items ():
142
146
result [key ] = value
143
147
return result
144
148
145
- # Overwrite configuration file on disk and reload it
146
149
@app .route ("/config" , methods = ["POST" ])
147
150
def handle_config ():
151
+ """
152
+ Overwrite configuration file on disk and reload it
153
+ """
148
154
Config .write (updateDict (app .bot_config , request .form ))
149
155
app .bot_config = Config .get ()
150
156
return "ok"
151
157
152
- # Expose configuration as JSON
153
158
@app .route ("/config" , methods = ["GET" ])
154
159
def returnConfig ():
160
+ """
161
+ Expose configuration as JSON
162
+ """
155
163
app .bot_config = Config .get ()
156
164
return (jsonify (app .bot_config ))
157
165
158
- # Changes wi-fi configuration and reboot
159
166
@app .route ("/wifi" , methods = ["POST" ])
160
167
def handle_wifi ():
168
+ """
169
+ Passes the received Wi-Fi configuration to the wifi.py script, applying it.
170
+ Then reboots
171
+ """
161
172
mode = request .form .get ("wifi_mode" )
162
173
ssid = request .form .get ("wifi_ssid" )
163
174
psk = request .form .get ("wifi_psk" )
@@ -172,12 +183,6 @@ def handle_wifi():
172
183
else :
173
184
return "http://coderbot.local"
174
185
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
-
181
186
# Execute single command
182
187
@app .route ("/bot" , methods = ["GET" ])
183
188
def handle_bot ():
0 commit comments