新建样式表、客户端脚本、上传表单及upload路由
This commit is contained in:
parent
24158f15a9
commit
4857119778
1
public/client.js
Normal file
1
public/client.js
Normal file
@ -0,0 +1 @@
|
||||
file_input.value = null
|
27
public/style.css
Normal file
27
public/style.css
Normal file
@ -0,0 +1,27 @@
|
||||
* {
|
||||
margin: 0px;
|
||||
padding: 0px;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
body {
|
||||
user-select: none;
|
||||
max-width: 360px;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
h1,
|
||||
form {
|
||||
margin: 1rem auto;
|
||||
}
|
||||
|
||||
form {
|
||||
display: grid;
|
||||
grid-template-columns: auto 1fr;
|
||||
gap: 1rem;
|
||||
}
|
||||
|
||||
form button {
|
||||
grid-column: span 2;
|
||||
cursor: pointer;
|
||||
}
|
16
server.js
16
server.js
@ -9,11 +9,21 @@ mongoose.connect(MONGODB_URL, (error) => {
|
||||
}
|
||||
})
|
||||
const app = express()
|
||||
app.use(express.static('public'))
|
||||
app.set('view engine', 'pug')
|
||||
app.get('/', async (req, res) => {
|
||||
res.render('index', { title: '文件分享服务器' })
|
||||
app.use(express.static('public'))
|
||||
app.use(express.urlencoded({ extended: true }))
|
||||
app.use(express.json())
|
||||
app.get('/', (req, res) => {
|
||||
res.render('index')
|
||||
})
|
||||
app.post('/upload', (req, res) => {
|
||||
res.sendStatus(201)
|
||||
})
|
||||
const server = app.listen(SERVER_PORT, SERVER_HOST, () => {
|
||||
console.info(`server is running at http://${SERVER_HOST}:${SERVER_PORT}`)
|
||||
})
|
||||
/**
|
||||
* "bcrypt": "^5.0.1",
|
||||
"md5-file": "^5.0.0",
|
||||
"multer": "^1.4.5-lts.1",
|
||||
*/
|
||||
|
@ -1,9 +1,20 @@
|
||||
doctype html
|
||||
html(lang='zh')
|
||||
head
|
||||
meta(charset="UTF-8")
|
||||
meta(http-equiv="X-UA-Compatible" content="IE=edge")
|
||||
meta(name="viewport" content="width=device-width, initial-scale=1.0")
|
||||
title #{title}
|
||||
meta(charset='UTF-8')
|
||||
meta(http-equiv='X-UA-Compatible' content='IE=edge')
|
||||
meta(name='viewport' content='width=device-width, initial-scale=1.0')
|
||||
link(rel='icon' href='/favicon.ico' type='image/x-icon')
|
||||
link(rel='stylesheet' href='/style.css')
|
||||
title 文件分享服务器
|
||||
body
|
||||
h1 #{title}
|
||||
h1 文件分享服务器
|
||||
if uploaded
|
||||
p= uploaded
|
||||
form(method='POST' action='/upload' enctype='multipart/form-data')
|
||||
label(for='file_input') 文件
|
||||
input(id='file_input' name='file' type='file' required)
|
||||
label(for='password_input') 密码
|
||||
input(id='password_input' name='password' type='password' autocomplete='off')
|
||||
button(id='share_button' type='submit') 分享
|
||||
script(src='/client.js')
|
||||
|
Loading…
Reference in New Issue
Block a user