Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
Echecs
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Elarouti Adam
Echecs
Commits
7eaa9843
Commit
7eaa9843
authored
4 months ago
by
De Brettes Thomas
Browse files
Options
Downloads
Patches
Plain Diff
Changement
parent
bf513292
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
Echec.html
+20
-0
20 additions, 0 deletions
Echec.html
server.js
+26
-9
26 additions, 9 deletions
server.js
with
46 additions
and
9 deletions
Echec.html
0 → 100644
+
20
−
0
View file @
7eaa9843
<!DOCTYPE html>
<html
lang=
"fr"
>
<head>
<meta
charset=
"UTF-8"
>
<meta
name=
"viewport"
content=
"width=device-width, initial-scale=1.0"
>
<title>
Jeu d'échecs
</title>
<style>
canvas
{
border
:
2px
solid
black
;
display
:
block
;
margin
:
20px
auto
;
}
</style>
</head>
<body>
<h1>
Jeu d'échecs
</h1>
<canvas
id=
"chessboard"
width=
"480"
height=
"480"
></canvas>
<script
src=
"chess.js"
></script>
</body>
</html>
This diff is collapsed.
Click to expand it.
server.js
+
26
−
9
View file @
7eaa9843
var
fs
=
require
(
'
fs
'
),
http
=
require
(
'
http
'
),
path
=
require
(
'
path
'
);
const
canvas
=
document
.
getElementById
(
"
chessboard
"
);
var
server
=
http
.
createServer
(
function
(
request
,
response
)
{
const
ctx
=
canvas
.
getContext
(
"
2d
"
);
var
filePath
=
path
.
join
(
__dirname
,
'
htdocs
'
,
request
.
url
===
'
/
'
?
'
index.html
'
:
request
.
url
);
const
size
=
60
;
for
(
let
row
=
0
;
row
<
8
;
row
++
)
{
fs
.
readFile
(
filePath
,
function
(
err
,
data
)
{
for
(
let
col
=
0
;
col
<
8
;
col
++
)
{
if
(
err
)
{
ctx
.
fillStyle
=
(
row
+
col
)
%
2
===
0
?
"
white
"
:
"
black
"
;
response
.
writeHead
(
404
,
{
'
Content-Type
'
:
'
text/plain; charset=utf-8
'
});
ctx
.
fillRect
(
col
*
size
,
row
*
size
,
size
,
size
);
response
.
end
(
'
Désolé, le document demandé est introuvable...
'
);
}
console
.
log
(
'
404
'
+
request
.
url
);
}
else
{
let
ext
=
path
.
extname
(
filePath
);
let
contentType
=
'
text/html
'
;
if
(
ext
===
'
.css
'
)
contentType
=
'
text/css
'
;
if
(
ext
===
'
.js
'
)
contentType
=
'
application/javascript
'
;
response
.
writeHead
(
200
,
{
'
Content-Type
'
:
contentType
+
'
; charset=utf-8
'
});
response
.
end
(
data
);
console
.
log
(
'
200
'
+
request
.
url
);
}
}
});
});
server
.
listen
(
8080
,
()
=>
{
console
.
log
(
"
Serveur démarré sur http://localhost:8080
"
);
});
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