Pet*_*ron 7 python asp.net-mvc web-frameworks
尽管我喜欢在ASP.NET MVC上构建,但现在是时候离开Windows了.
我想以最少的痛苦切换到基于Python的东西.
在没有讨论切换的优点或原因的情况下,哪个Python Web框架在体系结构方面与ASP.NET MVC 3最相似?
我说的是流程,而不是语言.
routes.MapRoute( // maps requests at /Product/ to ProductController
"Products", // Route name
"Product/{action}/{id}", // URL with parameters
new { controller = "Product", action = "Index", id = UrlParameter.Optional }
// Parameter defaults
);
Run Code Online (Sandbox Code Playgroud)
public class ProductController
{
public ActionResult Index(IndexInputModel inputModel)
{
// do something with inputModel ...
var viewModel = new ProductIndexViewModel()
{
Products = productList;
}
return View("~/Views/Product/Index.cshtml", viewModel);
}
// ...
}
Run Code Online (Sandbox Code Playgroud)
~/Views/Product/Index.cshtml.NET Razor视图@model ProductIndexViewModel
<h2>Products</h2>
@foreach (var product in Model.Products)
{
<h3>@product.Title</h3>
<p>@product.Description</p>
<span class="price">@product.Price</span>
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1021 次 |
| 最近记录: |