change abstract path

This commit is contained in:
monoid 2021-01-05 20:22:17 +09:00
parent 1a8b3d5d15
commit d88c65c26c
2 changed files with 9 additions and 9 deletions

View File

@ -4,11 +4,11 @@
<meta charset="UTF-8"> <meta charset="UTF-8">
<title>react-sample</title> <title>react-sample</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="./dist/css/style.css"> <link rel="stylesheet" href="/dist/css/style.css">
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,700&display=swap" /> <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,700&display=swap" />
</head> </head>
<body> <body>
<div id="root"></div> <div id="root"></div>
<script src="dist/js/bundle.js"></script> <script src="/dist/js/bundle.js"></script>
</body> </body>
</html> </html>

View File

@ -16,6 +16,7 @@ async function main(){
let app = new Koa(); let app = new Koa();
app.use(bodyparser()); app.use(bodyparser());
app.use(error_handler); app.use(error_handler);
const index_html = readFileSync("index.html");
let router = new Router(); let router = new Router();
let settings = get_setting(); let settings = get_setting();
@ -26,7 +27,7 @@ async function main(){
console.log(settings); console.log(settings);
router.get('/', async (ctx,next)=>{ router.get('/', async (ctx,next)=>{
ctx.type = "html"; ctx.type = "html";
ctx.body = readFileSync("index.html"); ctx.body = index_html;
}); });
router.get('/dist/css/style.css',async (ctx,next)=>{ router.get('/dist/css/style.css',async (ctx,next)=>{
ctx.type = "css"; ctx.type = "css";
@ -37,11 +38,10 @@ async function main(){
//ctx.set("",""); //ctx.set("","");
ctx.body = createReadStream("dist/js/bundle.js"); ctx.body = createReadStream("dist/js/bundle.js");
}); });
router.get('/get' router.get('/doc/:rest(.*)'
,async (ctx,next)=>{ ,async (ctx,next)=>{
ctx.body = ctx.query; ctx.type = "html";
console.log(JSON.stringify(ctx.query)); ctx.body = index_html;
await next();
} }
); );
let content_router = getContentRouter(createKnexContentsAccessor(db)); let content_router = getContentRouter(createKnexContentsAccessor(db));
@ -58,7 +58,7 @@ async function main(){
app.use(router.routes()); app.use(router.routes());
app.use(router.allowedMethods()); app.use(router.allowedMethods());
console.log("log"); console.log("start server");
app.listen(3002); app.listen(3002);
return app; return app;
} }