# 前端数据库连接服务 **Repository Path**: yfly666/web-mysql-server ## Basic Information - **Project Name**: 前端数据库连接服务 - **Description**: 前端写sql操作数据库 - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2023-11-15 - **Last Updated**: 2023-11-17 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README ## web-mysql-server 前端数据库连接服务 ## 初始化 ``` 安装nodejs后在本目录下执行 npm run init //如果卡住了可以尝试安装cnpm后用cnpm替换npm ``` ## 修改index.js中的数据库配置和服务端口号 ``` //修改数据库配置为自己的 DB.config = { host: '10.5.21.10', port:3306, user:'hw', password: 'hw', database: 'hw' } //默认端口8080 httpServer.listen(8080, '0.0.0.0', function () { console.log('HTTP Server is running'); }) ``` ### 启动服务 ``` npm run server ``` ### 静态文件 ``` 放在www文件夹,访问 http://localhost:8080 ``` ### 访问数据库接口 ``` url:http://localhost:8080/eval method:POST data:{ sql:'select * from user;' } ``` ### 文件上传接口 ``` url:http://localhost:8080/upload method:POST 文件字段关键字file ``` ### 文件访问接口 ``` url:http://localhost:8080/file/:filename method:GET ```