• 四种语言实现最简单的web server


    语言:Java

    框架:Spring Boot

     1 package com.example.springboot01.controller;
     2 
     3 import org.springframework.web.bind.annotation.RequestMapping;
     4 import org.springframework.web.bind.annotation.RestController;
     5 
     6 @RestController
     7 public class indexController {
     8 
     9     @RequestMapping("/")
    10     public String Index(){
    11         return "hello world Spring Boot";
    12     }
    13 }

    语言:JavaScript(Node.js)

    框架:Express

    1 const express = require('express')
    2 const  app = express()
    3 app.get('/',(req,res)=>{
    4     res.send('hello world Express')
    5 })
    6 app.listen(10000,()=>{
    7     console.log('开始监听端口:10000')
    8 })

    语言:Python

    框架:Flask

    1 from flask import Flask
    2 app = Flask(__name__)
    3 @app.route('/')
    4 def index():
    5     return 'hello world Flask'
    6 if __name__ == '__main__':
    7     print('开始监听端口:5000')
    8     app.run()

    语言:C#

    框架:Asp.Net Web Api

     1 using System;
     2 using System.Web.Mvc;
     3 
     4 namespace WebApplication1.Controllers
     5 {
     6     public class HomeController : Controller
     7     {
     8         public String Index()
     9         {
    10             return "hello world Asp.Net Web Api";
    11         }        
    12     }
    13 }
  • 相关阅读:
    CodeForces 514B
    CodeForces 514A
    UVa 818
    HDU 1003
    UVa百题总结
    UVa 11526
    UVa 12412
    UVa 211
    UVa 1587
    UVa 225 – Golygons [DFS+剪枝]
  • 原文地址:https://www.cnblogs.com/asenyang/p/15407410.html
Copyright © 2020-2023  润新知