Server side done
This commit is contained in:
9
client/Dockerfile
Normal file
9
client/Dockerfile
Normal file
@@ -0,0 +1,9 @@
|
||||
FROM nginx:latest
|
||||
|
||||
ADD ./ /frontend
|
||||
|
||||
RUN mv ./frontend/Private/nginx.conf /etc/nginx/nginx.conf
|
||||
|
||||
RUN mv ./frontend/Public/* /usr/share/nginx/html/
|
||||
|
||||
CMD ["nginx"]
|
19
client/Private/nginx.conf
Normal file
19
client/Private/nginx.conf
Normal file
@@ -0,0 +1,19 @@
|
||||
worker_processes auto;
|
||||
daemon off;
|
||||
error_log nginx_error.log;
|
||||
events {
|
||||
worker_connections 1024;
|
||||
}
|
||||
|
||||
http {
|
||||
include /etc/nginx/mime.types;
|
||||
server {
|
||||
|
||||
location /submit {
|
||||
proxy_pass http://tradegame/submit;
|
||||
}
|
||||
location / {
|
||||
root /usr/share/nginx/html;
|
||||
}
|
||||
}
|
||||
}
|
20
client/Public/index.html
Normal file
20
client/Public/index.html
Normal file
@@ -0,0 +1,20 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>🚂Vote Train🚂</title>
|
||||
<link href="https://unpkg.com/tailwindcss@^2/dist/tailwind.min.css" rel="stylesheet">
|
||||
<script type="text/javascript" src="script.js"></script>
|
||||
</head>
|
||||
<body class="">
|
||||
<div class="justify-center text-center text-white sm:text-lg bg-green-200 sm:p-20 h-full m-36 sm:rounded-3xl">
|
||||
<div id="input" class="py-10 sm:max-w-xl mx-auto font-mono">
|
||||
<form action="javascript:void(0)" class="shadow-2xl sm:rounded-r-full sm:p-10 bg-gradient-to-t from-black to-gray-500 tracking-widest">
|
||||
<input type="text" placeholder="key" class="text-black" id="key"/><br>
|
||||
Upvote: <input type="checkbox" id="upvote"/><br>
|
||||
Downvote: <input type="checkbox" id="downvote"/><br>
|
||||
<button onclick="send()" class="bg-gray-600 ">Submit</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
21
client/Public/script.js
Normal file
21
client/Public/script.js
Normal file
@@ -0,0 +1,21 @@
|
||||
async function send(){
|
||||
data={
|
||||
key:document.getElementById("key").value,
|
||||
upvote: document.getElementById("upvote").checked,
|
||||
downvote:document.getElementById("downvote").checked,
|
||||
|
||||
}
|
||||
let response = await fetch('/submit', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json;charset=utf-8'
|
||||
},
|
||||
body: JSON.stringify(data)
|
||||
})
|
||||
|
||||
let result = await response.json();
|
||||
console.log(response.json)
|
||||
document.getElementById("input").innerHTML=result.text
|
||||
|
||||
|
||||
}
|
3
client/README.md
Normal file
3
client/README.md
Normal file
@@ -0,0 +1,3 @@
|
||||
# frontend
|
||||
|
||||
Contains files for the web application and nginx proxy server configuration
|
Reference in New Issue
Block a user