mirror of
https://onedev.site.tesses.net/crosslang/crosslang-tutorials
synced 2026-02-08 17:15:46 +00:00
First commit
This commit is contained in:
10
2 Embedding files/cross.json
Normal file
10
2 Embedding files/cross.json
Normal file
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"dependencies": [
|
||||
],
|
||||
"info": {
|
||||
"license": "MIT",
|
||||
"type": "webapp"
|
||||
},
|
||||
"name": "MyWebApp",
|
||||
"version": "1.0.0.0-prod"
|
||||
}
|
||||
BIN
2 Embedding files/res/mountain.jpg
Normal file
BIN
2 Embedding files/res/mountain.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.9 MiB |
22
2 Embedding files/src/main.tcross
Normal file
22
2 Embedding files/src/main.tcross
Normal file
@@ -0,0 +1,22 @@
|
||||
|
||||
func WebAppMain(args)
|
||||
{
|
||||
return (ctx)=>{
|
||||
if(ctx.Path == "/")
|
||||
{
|
||||
ctx.WithMimeType("text/html").SendText(<img src="mountain.jpg">);
|
||||
return true;
|
||||
}
|
||||
else if(ctx.Path == "/mountain.jpg")
|
||||
{
|
||||
var mypicture = embed("mountain.jpg");
|
||||
ctx.WithMimeType("image/jpeg").SendBytes(mypicture);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
}
|
||||
func main(args)
|
||||
{
|
||||
Console.WriteLine("use crosslang webapp-test to test");
|
||||
}
|
||||
Reference in New Issue
Block a user