Skip to content

Commit

Permalink
havent got a clue
Browse files Browse the repository at this point in the history
  • Loading branch information
owencz1998 committed Oct 7, 2023
1 parent 92af826 commit 047468c
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 45 deletions.
12 changes: 0 additions & 12 deletions deno.jsonc

This file was deleted.

4 changes: 4 additions & 0 deletions dist/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"deno.enable": true,
"deno.unstable": true
}
12 changes: 12 additions & 0 deletions dist/deno.jsonc
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"
}
}
33 changes: 33 additions & 0 deletions dist/server.ts
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 });
33 changes: 0 additions & 33 deletions server.ts

This file was deleted.

1 comment on commit 047468c

@deno-deploy
Copy link

@deno-deploy deno-deploy bot commented on 047468c Oct 7, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Failed to deploy:

Module not found "file:///src/server.ts".

Please sign in to comment.