uboot: redirect "/cgi-bin/luci" to index.html

This commit is contained in:
hanwckf
2023-08-31 01:36:12 +08:00
parent 75df87ca34
commit 62f26ff5de
8 changed files with 25 additions and 17 deletions

View File

@@ -144,6 +144,14 @@ static void not_found_handler(enum httpd_uri_handler_status status,
}
}
static void index_handler(enum httpd_uri_handler_status status,
struct httpd_request *request,
struct httpd_response *response)
{
if (status == HTTP_CB_NEW)
output_plain_file(response, "index.html");
}
static void html_handler(enum httpd_uri_handler_status status,
struct httpd_request *request,
struct httpd_response *response)
@@ -151,9 +159,7 @@ static void html_handler(enum httpd_uri_handler_status status,
if (status != HTTP_CB_NEW)
return;
if (!strcmp(request->urih->uri, "/"))
output_plain_file(response, "index.html");
else if (output_plain_file(response, request->urih->uri + 1))
if (output_plain_file(response, request->urih->uri + 1))
not_found_handler(status, request, response);
}
@@ -436,7 +442,9 @@ int start_web_failsafe(void)
return -1;
}
httpd_register_uri_handler(inst, "/", &html_handler, NULL);
httpd_register_uri_handler(inst, "/", &index_handler, NULL);
httpd_register_uri_handler(inst, "/cgi-bin/luci", &index_handler, NULL);
httpd_register_uri_handler(inst, "/cgi-bin/luci/", &index_handler, NULL);
#ifdef CONFIG_MT7981_BOOTMENU_EMMC
httpd_register_uri_handler(inst, "/gpt.html", &html_handler, NULL);
#endif

View File

@@ -5,8 +5,8 @@
<meta http-equiv="Cache-Control" content="no-cache" />
<meta http-equiv="refresh" content="2; URL=/" />
<title>Page not found</title>
<link rel="stylesheet" href="style.css">
<script src="index.js"></script>
<link rel="stylesheet" href="/style.css">
<script src="/index.js"></script>
</head>
<body onload="getversion()">
<div id="m">

View File

@@ -3,8 +3,8 @@
<head>
<meta charset="utf-8">
<title>U-Boot update</title>
<link rel="stylesheet" href="style.css">
<script src="index.js"></script>
<link rel="stylesheet" href="/style.css">
<script src="/index.js"></script>
</head>
<body onload="getversion()">
<div id="m">

View File

@@ -3,8 +3,8 @@
<head>
<meta charset="utf-8">
<title>Update failed</title>
<link rel="stylesheet" href="style.css">
<script src="index.js"></script>
<link rel="stylesheet" href="/style.css">
<script src="/index.js"></script>
</head>
<body onload="getversion()">
<div id="m">

View File

@@ -5,7 +5,7 @@
<title>Update in progress</title>
<style>h1,p,ul{margin:0;padding:0}html,body{font:13px/20px Arial,sans-serif;background:#EDEDED}#m{max-width:750px;margin:30px auto 10px;border:solid 1px #BABABA;background:#FFF;border-radius:7px;box-shadow:0 0 10px #D2D1D1}#m > *{padding:20px}h1{font:bold 50px/50px Tahoma;border-bottom:solid 1px #E8E8E8}a,h1{color:#2450AD;text-decoration:none}.i{margin:20px;border-radius:7px;text-align:justify}.w{background:#FEFDCE;border:solid 1px #FFC643}#version{text-align:center;}form,p,h1{text-align:center}ul{list-style:square;margin:0 0 0 20px}.i strong{margin:0 0 5px;display:block}#l{height:30px;width:30px;margin:0 auto 20px;-webkit-animation:r 1s infinite linear;-moz-animation:r 1s infinite linear;-o-animation:r 1s infinite linear;animation:r 1s infinite linear;border-left:7px solid #EAF1FF;border-right:7px solid #EAF1FF;border-bottom:7px solid #EAF1FF;border-top:7px solid #2450AD;border-radius:100%}@-webkit-keyframes r{from{-webkit-transform:rotate(0deg)}to{-webkit-transform:rotate(359deg)}}@-moz-keyframes r{from{-moz-transform:rotate(0deg)}to{-moz-transform:rotate(359deg)}}@-o-keyframes r{from{-o-transform:rotate(0deg)}to{-o-transform:rotate(359deg)}}@keyframes r{from{transform:rotate(0deg)}to{transform:rotate(359deg)}}
</style>
<script src="index.js"></script>
<script src="/index.js"></script>
<script>
function init() {
getversion()

View File

@@ -3,8 +3,8 @@
<head>
<meta charset="utf-8">
<title>U-Boot update</title>
<link rel="stylesheet" href="style.css">
<script src="index.js"></script>
<link rel="stylesheet" href="/style.css">
<script src="/index.js"></script>
</head>
<body onload="getversion()">
<div id="m">

View File

@@ -3,8 +3,8 @@
<head>
<meta charset="utf-8">
<title>Firmware update</title>
<link rel="stylesheet" href="style.css">
<script src="index.js"></script>
<link rel="stylesheet" href="/style.css">
<script src="/index.js"></script>
</head>
<body onload="startup()">
<div id="m">

View File

@@ -3,8 +3,8 @@
<head>
<meta charset="utf-8">
<title>U-Boot update</title>
<link rel="stylesheet" href="style.css">
<script src="index.js"></script>
<link rel="stylesheet" href="/style.css">
<script src="/index.js"></script>
</head>
<body onload="getversion()">
<div id="m">