Python (使用Flask框架创建简单的Web应用)
python
from flask import Flask
app = Flask(name) 0512px.cn
@app.route(‘/’)
def hello_world():
return ‘Hello, World!’
if name == ‘main’:
app.run()
JavaScript (Node.js)
javascript
const http = require(‘http’);
const server = http.createServer((req, res) => {
res.writeHead(200, {‘Content-Type’: ‘text/plain’});
res.end(‘Hello, World!’);
});
const PORT = process.env.PORT || 3000;
server.listen(PORT, () => {
console.log(Server is running on port ${PORT}
);
});
Java (使用Spring Boot创建REST API)
在Spring Boot项目中,你可以创建一个Controller:
java
import org.springframework.web.bind.annot