File tree Expand file tree Collapse file tree 3 files changed +1
-26
lines changed
Expand file tree Collapse file tree 3 files changed +1
-26
lines changed Original file line number Diff line number Diff line change 11use std:: env;
22mod io_methods;
33mod api_methods;
4+ mod cache;
45
56#[ tokio:: main]
67async fn main ( ) {
Original file line number Diff line number Diff line change @@ -3,38 +3,12 @@ import Fastify from 'fastify';
33export async function createHttpServer ( ) {
44 const fastify = Fastify ( { logger : true } ) ;
55
6- // Route to send a chat message and receive a response
76 fastify . post ( '/chat' , async ( request , reply ) => {
87 const { message } = request . body as { message : string } ;
98 const responseMessage = `Received your message: ${ message } ` ;
109 return { response : responseMessage } ;
1110 } ) ;
1211
13- // Route to serve the dashboard page
14- fastify . get ( '/dashboard' , async ( request , reply ) => {
15- const dashboardHtml = `
16- <html>
17- <head>
18- <title>Dashboard</title>
19- </head>
20- <body>
21- <h1>Application Logs</h1>
22- <ul id="logs"></ul>
23- <script>
24- const eventSource = new EventSource('/logs');
25- eventSource.onmessage = function(event) {
26- const logList = document.getElementById('logs');
27- const newLog = document.createElement('li');
28- newLog.textContent = event.data;
29- logList.appendChild(newLog);
30- };
31- </script>
32- </body>
33- </html>
34- ` ;
35- reply . type ( 'text/html' ) . send ( dashboardHtml ) ;
36- } ) ;
37-
3812 try {
3913 await fastify . listen ( { port : 3000 , host : '0.0.0.0' } ) ;
4014 console . log ( 'Server is running at http://localhost:3000' ) ;
You can’t perform that action at this time.
0 commit comments