1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- var express = require('express');
- var app = express();
- var bodyParser = require('body-parser');
- var upload = require('./js/upload');
- app.use(bodyParser.json());
- app.use(bodyParser.urlencoded({extended: false}));
- /*function generateUUID() { // Public Domain/MIT
- var d = new Date().getTime();
- if (typeof performance !== 'undefined' && typeof performance.now === 'function'){
- d += performance.now(); //use high-precision timer if available
- }
- return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
- var r = (d + Math.random() * 16) % 16 | 0;
- d = Math.floor(d / 16);
- return (c === 'x' ? r : (r & 0x3 | 0x8)).toString(16);
- });
- }*/
- //asdsadsa
- //测试
- // 首页
- app.get('/', function (req, res) {
- res.redirect('/file')
- });
- // 静态网页
- app.use('/file', express.static('src'));
- // 上传完成的文件
- app.use('/uploadFile', express.static('upload'));
- // 上传页面
- app.post('/upload', upload);
- // 启动服务器
- var server = app.listen(3000, function () {
- var host = server.address().address;
- var port = server.address().port;
- console.log('Listening at http://%s:%s', host, port);
- });
|