This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void main() { | |
Human jenny = Human(startingHeight: 15); | |
print(jenny.height); | |
Human jemes = Human(startingHeight: 20); | |
print(jemes.height); | |
jemes.talk("hello"); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void main() { | |
Human jenny = Human(15, 40); | |
print(jenny.height); | |
Human jemes = Human(110, 10); | |
print(jemes.height); | |
print(jemes.weight); | |
jemes.talk("hello"); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:flutter/material.dart'; | |
void main() => runApp(MyApp()); | |
class MyApp extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
return MaterialApp( | |
home: Screen1(), | |
); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:flutter/material.dart'; | |
void main() => runApp(MyApp()); | |
class MyApp extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
return MaterialApp( | |
initialRoute: "/", | |
routes: { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'dart:io'; | |
void main() { | |
performTask(); | |
} | |
void performTask() async { | |
task1(); | |
String task2result = await task2(); | |
task3(task2result); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void main() { | |
Car myCar = Car(); | |
print(myCar.numberOfSeat); | |
myCar.drive(); | |
ElectriCar myTesla = ElectriCar(); | |
myTesla.drive(); | |
print(myTesla.batteryLevel); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const http = require("http"); | |
const https = require("https"); | |
const fs = require("fs"); | |
const express = require("express"); | |
const app = express(); | |
// http server | |
const http_server = http.createServer(app); | |
http_server.listen(80, "0.0.0.0"); | |
const options = { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function ajax(method, url, data) { | |
var request = new XMLHttpRequest(); | |
return new Promise(function (resolve, reject) { | |
request.onreadystatechange = function () { | |
if (request.readyState === 4) { | |
if (request.status === 200) { | |
resolve(request.responseText); | |
} else { | |
reject(reject(reject.status)); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const koa = require("koa"); | |
const app = new koa(); | |
app.use(async (ctx, next) => { | |
let stime = new Date().getTime(); | |
await next(); | |
let etime = new Date().getTime(); | |
ctx.response.type = "text/html"; | |
ctx.response.body = "<h1>Hello World</h1>"; | |
console.log(`请求地址:${ctx.path},响应时间:${etime - stime}`); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const koa = require("koa"); | |
const app = new koa(); | |
const bodyParser = require("koa-bodyparser"); | |
app.use(bodyParser()); | |
app.use(async ctx => { | |
if (ctx.url === "/" && ctx.method === "GET") { | |
ctx.type = "html"; | |
let html = ` | |
<h1>登录</h1> |