Add /code/ for online editing

This commit is contained in:
Scott Shawcroft 2022-08-16 15:44:58 -07:00
parent 4b1d1fd72d
commit 525eb711c1
No known key found for this signature in database
GPG Key ID: 0DFD512649C052DA
3 changed files with 16 additions and 1 deletions

View File

@ -0,0 +1,12 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Online Code Editor</title>
</head>
<body>
<script type="module" src="https://code.circuitpython.org/assets/js/device.js"></script>
</body>
</html>

View File

@ -2,7 +2,7 @@
<html lang="en"> <html lang="en">
<head> <head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<title>Code Edit</title> <title>Offline Code Edit</title>
<link rel="stylesheet" href="http://circuitpython.org/assets/css/webworkflow-8.css"> <link rel="stylesheet" href="http://circuitpython.org/assets/css/webworkflow-8.css">
<link rel="stylesheet" href="/style.css"> <link rel="stylesheet" href="/style.css">
</head> </head>

View File

@ -926,6 +926,7 @@ static void _write_file_and_reply(socketpool_socket_obj_t *socket, _request *req
#define STATIC_FILE(filename) extern uint32_t filename##_length; extern uint8_t filename[]; extern const char *filename##_content_type; #define STATIC_FILE(filename) extern uint32_t filename##_length; extern uint8_t filename[]; extern const char *filename##_content_type;
STATIC_FILE(code_html);
STATIC_FILE(directory_html); STATIC_FILE(directory_html);
STATIC_FILE(directory_js); STATIC_FILE(directory_js);
STATIC_FILE(welcome_html); STATIC_FILE(welcome_html);
@ -1143,6 +1144,8 @@ static bool _reply(socketpool_socket_obj_t *socket, _request *request) {
} else { } else {
_REPLY_STATIC(socket, request, edit_html); _REPLY_STATIC(socket, request, edit_html);
} }
} else if (strcmp(request->path, "/code/") == 0) {
_REPLY_STATIC(socket, request, code_html);
} else if (strncmp(request->path, "/cp/", 4) == 0) { } else if (strncmp(request->path, "/cp/", 4) == 0) {
const char *path = request->path + 3; const char *path = request->path + 3;
if (strcasecmp(request->method, "OPTIONS") == 0) { if (strcasecmp(request->method, "OPTIONS") == 0) {