Git Product home page Git Product logo

tinyhttpservice's Introduction

TinyHttpService

简单的Http服务,可以根据http请求进行常见的操作。只需在你的程序(这个程序可以是WPF/Winform/Console等等)中引用并使用,你的程序就变成了一个简单的Http服务器了。这样你的程序就可以根据http请求做你想做的事了,比如:在web页面上操纵你的应用程序,进行文件上传下载等等。

使用方法

###首先注册路由: var routes = RouteTable.Instance;

routes.Get("/user", (context) =>
{
    var user = new User();
    user.UserName = "zhang";
    return new ViewResult<User>("/view/razor.cshtml", user);
});

routes.Post("/user", (context) =>
{
    Console.WriteLine(context.Request.Body.ToString());

    //如果你的程序是wpf程序,需要控制UI元素,你需要使用:
    //Element.Dispatcher.Invoke方法或者Elment.Dispatcher.BeginInvoke方法
    return new ContentResult("haha");
});

###然后监听请求: TinyHttpService service = DefaultTinyHttpServiceFactory.GetDefaultTinyHttpService(); service.Bind(5000);

提醒:如果在你的项目中创建了页面文件和其他的静态文件,你需要将它们输出到bin文件夹下。(右键文件,选择属性,在复制到输出目录下选择总是复制或者复制新文件)。

tinyhttpservice's People

Contributors

zh6335901 avatar zhanghao-kooboo avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.