Gitlab@Informatics
Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
Project
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
65160394
Project
Commits
73ef59e8
Commit
73ef59e8
authored
2 months ago
by
65160394
Browse files
Options
Downloads
Patches
Plain Diff
commit 1
parent
2d6e3897
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
server.js
+22
-5
22 additions, 5 deletions
server.js
views/index.ejs
+2
-2
2 additions, 2 deletions
views/index.ejs
with
24 additions
and
7 deletions
server.js
+
22
−
5
View file @
73ef59e8
...
...
@@ -6,18 +6,35 @@ const bodyParser = require("body-parser");
const
app
=
express
();
const
PORT
=
process
.
env
.
PORT
||
3000
;
app
.
use
(
express
.
json
());
app
.
use
(
express
.
urlencoded
({
extended
:
true
}));
// Database configuration
const
pool
=
mysql
.
createPool
({
host
:
process
.
env
.
pool
_HOST
,
port
:
process
.
env
.
pool
_PORT
,
user
:
process
.
env
.
pool
_USER
,
password
:
process
.
env
.
pool
_PASSWORD
,
database
:
process
.
env
.
pool
_NAME
,
host
:
process
.
env
.
DB
_HOST
,
port
:
process
.
env
.
DB
_PORT
,
user
:
process
.
env
.
DB
_USER
,
password
:
process
.
env
.
DB
_PASSWORD
,
database
:
process
.
env
.
DB
_NAME
,
waitForConnections
:
true
,
connectionLimit
:
10
,
queueLimit
:
0
});
// Check database connection
async
function
testConnection
()
{
try
{
const
connection
=
await
pool
.
getConnection
();
await
connection
.
ping
();
console
.
log
(
'
Database connection succeeded.
'
);
connection
.
release
();
}
catch
(
err
)
{
console
.
error
(
'
Database connection failed:
'
,
err
);
process
.
exit
(
1
);
// Terminate the app if the database connection fails
}
}
testConnection
();
// ตั้งค่า Middleware
app
.
set
(
"
view engine
"
,
"
ejs
"
);
app
.
use
(
bodyParser
.
urlencoded
({
extended
:
true
}));
...
...
This diff is collapsed.
Click to expand it.
views/index.ejs
+
2
−
2
View file @
73ef59e8
...
...
@@ -7,11 +7,11 @@
</head>
<body>
<h1>
รายการทัวร์
</h1>
<!--
<ul>
<ul>
<
%
tours.forEach(tour =
>
{
%
>
<li><
%=
tour.name
%
>
-
<
%=
tour.location
%
>
- $
<
%=
tour.price
%
></li>
<
%
})
%
>
</ul>
-->
</ul>
<h2>
เพิ่มทัวร์ใหม่
</h2>
<form
action=
"/add"
method=
"POST"
>
<input
type=
"text"
name=
"name"
placeholder=
"ชื่อทัวร์"
required
>
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment