from flask import Flask app = Flask(__name__) @app.route('/') defindex(): return'Hello, world' if __name__ == '__main__': app.run(debug=True)
在flask00的路徑執行python helloflask.py會出現如下的畫面
1 2 3 4 5 6 7 8 9 10 11
* Serving Flask app "helloflask" (lazy loading) * Environment: production WARNING: Do not use the development server in a production environment. Use a production WSGI server instead. * Debug mode: on * Restarting with stat * Debugger is active! * Debugger PIN: 313-752-154 * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit) 127.0.0.1 - - [12/Apr/2019 13:43:04] "GET / HTTP/1.1" 200 - 127.0.0.1 - - [12/Apr/2019 13:43:04] "GET /favicon.ico HTTP/1.1" 404 -
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace LinqTip { class Program { public enum Teams { Valor, Mystic, Instinct, Dark } public class Trainer { public Teams Team; public string Name; public Trainer(Teams team, string name) { Team = team; Name = name; } } static void Main(string[] args) { //來源資料如下 List<Trainer> trainers = new List<Trainer>() { new Trainer(Teams.Valor, "Candela"), new Trainer(Teams.Valor, "Bob"), new Trainer(Teams.Mystic, "Blanche"), new Trainer(Teams.Valor, "Alice"), new Trainer(Teams.Instinct, "Spark"), new Trainer(Teams.Mystic, "Tom"), new Trainer(Teams.Dark, "Jeffrey") }; //目標:以Team分類,將同隊的訓練師集合成List<Trainer>, //最終產出Dictionary<Teams, List<Trainer>> //以前的寫法,跑迴圈加邏輯比對 var res1 = new Dictionary<Teams, List<Trainer>>(); foreach (var t in trainers) { if (!res1.ContainsKey(t.Team)) res1.Add(t.Team, new List<Trainer>()); res1[t.Team].Add(t); } //新寫法,使用LINQ GroupBy var res2 = trainers.GroupBy(o => o.Team) .ToDictionary(o => o.Key, o => o.ToList()); } } }
[Service] WorkingDirectory=/home/wwwdata/wwwshop ExecStart=/usr/bin/dotnet /home/wwwdata/wwwshop/Gomo.CC.UI.Portal.dll Restart=always RestartSec=10 # Restart service after 10 seconds if dotnet service crashes SyslogIdentifier=dotnet-gomoshop User=root Environment=ASPNETCORE_ENVIRONMENT=Production