
hello world
相关链接
在使用过程中,有任何问题都可以通过以上链接找寻答案,或者联系我们。
这是一篇自动生成的文章,请删除这篇文章之后开始你的创作吧!
print('hello world')
public class App {
public static void main(String[] args) throws Exception {
System.out.println("Hello, World!");
}
}
#include <stdio.h>
int main() {
printf("hello world! /n");
return 0;
}
node写简单的后端服务
var express =require("express");
var app =express();
app.use(express.static('public'))
//参数‘/’可当作设置url的根显示页面,这里即”http://localhost:3000/“访问的页面设置为youtobe.html
app.get('/',(req,res)=>{
res.sendFile(__dirname+"/"+"youtobe.html") //设置/ 下访问文件位置
});
//设置端口3000访问地址,即http://localhost:3000
var server =app.listen(3000,()=>{
var port =server.address().port
console.log("访问地址http://localhost:%s",port)
})
node实现连接数据库
使用npm管理安装mysql
npm install mysql2
const mysql = require('mysql2');
const connection = mysql.createConnection({
host: 'localhost',
user: 'root',
password: 'fl3692458121',
database: 'xtsdb',
port: 3306,
});
connection.connect((err) => {
if (err) {
console.error('数据库连接失败: ' + err.stack);
return;
}
console.log('已连接到数据库');
connection.query('SELECT * FROM xts_test', (error, results, fields) => {
if (error) {
console.error('查询失败: ' + error.stack);
} else {
console.log('查询结果:', results);
}
connection.end((err) => {
if (err) {
console.error('关闭连接失败: ' + err.stack);
} else {
console.log('数据库连接已关闭');
}
});
});
});
本文是原创文章,采用 CC BY-NC-ND 4.0 协议,完整转载请注明来自 小天使的小窝
评论
匿名评论
隐私政策
你无需删除空行,直接评论以获取最佳展示效果
音乐天地