-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
92af826
commit 047468c
Showing
5 changed files
with
49 additions
and
45 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"deno.enable": true, | ||
"deno.unstable": true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"fmt": { | ||
"options": { | ||
"singleQuote": true, | ||
"indentWidth": 4 | ||
} | ||
}, | ||
"tasks": { | ||
"start": "deno run --allow-net --allow-read server.ts", | ||
"dev": "deno run --allow-net --allow-read --watch server.ts" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { Application } from 'https://deno.land/x/[email protected]/mod.ts'; | ||
|
||
const app = new Application(); | ||
|
||
// Send static content | ||
app.use(async (ctx, next) => { | ||
try { | ||
await ctx.send({ | ||
root: `${Deno.cwd()}/public/`, | ||
index: 'index.html', | ||
}); | ||
} catch { | ||
await next(); | ||
} | ||
}); | ||
|
||
// 404 handler (redirect to index.html) | ||
app.use((ctx) => { | ||
// handle index.html not found | ||
if ( | ||
ctx.request.url.pathname === '/' || | ||
ctx.request.url.pathname === '/index.html' | ||
) { | ||
ctx.response.status = 404; | ||
ctx.response.body = 'Not found.\nSeems index.html is missing.'; | ||
return; | ||
} | ||
ctx.response.status = 301; | ||
ctx.response.redirect('/'); | ||
}); | ||
|
||
console.log('App listening on port', 3000); | ||
await app.listen({ port: 3000 }); |
047468c
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Failed to deploy: