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('数据库连接已关闭');
}
});
});
});
git bash 上传命令
# 1. 进入项目文件夹(必须先 cd 进去!)
cd /c/Users/你的用户名/Desktop/你的项目文件夹
# 或者直接右键文件夹 → "Git Bash Here"
# 2. 初始化 git(如果这个文件夹还没被 git 管理过)
git init
# 3. 添加所有文件到暂存区
git add .
# 4. 提交到本地仓库(第一次建议写清楚)
git commit -m "初次提交:完整项目结构"
# 5. 在 GitHub 网页先创建一个空仓库(不要勾选 README/.gitignore)
# 然后复制仓库地址(推荐用 HTTPS 或 SSH)
# 6. 关联远程仓库(把下面地址换成你自己的)
git remote add origin https://github.com/你的用户名/仓库名.git
# 或者用 SSH(更推荐,以后不用每次输密码):
# git remote add origin git@github.com:你的用户名/仓库名.git
# 7. 第一次推送(-u 建立跟踪关系,以后可以直接 git push)
git push -u origin main
# 如果远程仓库默认分支是 master,就改成:
# git push -u origin master
本文是原创文章,采用 CC BY-NC-ND 4.0 协议,完整转载请注明来自 小天使
评论
匿名评论
隐私政策
你无需删除空行,直接评论以获取最佳展示效果
音乐天地