Python Web Framework最像ASP.NET MVC 3

Pet*_*ron 7 python asp.net-mvc web-frameworks

尽管我喜欢在ASP.NET MVC上构建,但现在是时候离开Windows了.

我想以最少的痛苦切换到基于Python的东西.

在没有讨论切换的优点或原因的情况下,哪个Python Web框架在体系结构方面与ASP.NET MVC 3最相似?

建筑实例

我说的是流程,而不是语言.

典型的.NET路由

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)

典型的.NET控制器

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)

Kla*_*sen 2

Django有一些相似之处。但是 python 不像 .Net 那样强类型,所以我认为无论您最终使用哪个框架,您都会看到相当多的差异。