12345678910111213141516171819202122232425262728 |
- import express from 'express'
- import cors from 'cors'
- import bodyParser from 'body-parser'
- import multiparty from 'connect-multiparty'
- const port = 3000
- // 创建 app
- const app = express()
- // 设置跨域访问
- app.use(cors())
- // 处理POST参数
- // 处理 x-www-form-urlencoded
- app.use(bodyParser.urlencoded({
- extended:true
- }));
- // 处理 application/json
- app.use(bodyParser.json())
- // 处理 mutipart/form-data
- app.use(multiparty())
- import shipTestRouter from "./ship-test/routers/index.js";
- app.use('/ship-test', shipTestRouter)
- // 启动
- app.listen(port, () => {
- console.log('express server running at ' + port);
- })
|