TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Ivan Climov
1.1k
692
22.4k
How to make the data (JSON) from the POST request automatica
Jul 4 2019 1:55 PM
I try to make a WinForm application with a web server.
Did so:
1. I use github.com - "eske / SimpleHttpServer" - link
(https://github.com/jeske/SimpleHttpServer).
2. Created a WinForm project.
3. Added a link to the library project SimpleHttpServer
.. \ SimpleHttpServer \ bin \ Debug \ SimpleHttpServer.dll
4. Added code to Form1. (see below "My Code").
Questions
1. Have I correctly connected the server and WinForm?
2. How to make the data (JSON) that is transmitted in a POST request to my server automatically fall into the variable I need in WinForm?
In other words: as soon as the POST request arrives at the server, the data is automatically placed in the variable.
My goal: to get acquainted with the principles of work Viber Api.
For this, I propose to host the application on the local computer.
WinWorm (user interface), which will interact with the server Viber Api). Everything is placed on one computer and used by one user.
With the help of Ngrok application will be open to the Internet.
The Ngrok service provides links forhttp: // localhost: XXXXX links like https: // 6eb5a091.ngrok.io /
My code.
private
void
Form1_Load(
object
sender, EventArgs e)
{
StartHttpServer();
}
static
void
StartHttpServer()
{
try
{
// var route_config = new List
()
var route_config =
new
List
()
{
new
Route
{
Name =
"?????? ?????????? (Hello Handler)"
,
UrlRegex = @
"^/$"
,
Method =
"GET"
,
Callable = (HttpRequest request) =>
{
return
new
HttpResponse()
{
ContentAsUTF8 =
"?????? ?? ???????? ??????? Http (Hello from SimpleHttpServer)"
,
ReasonPhrase =
"OK"
,
StatusCode =
"200"
};
}
},
//new Route {
// Name = "FileSystem Static Handler",
// UrlRegex = @"^/Static/(.*)$",
// Method = "GET",
// Callable = new FileSystemRouteHandler() { BasePath = @"C:\Tmp", ShowDirectories=true }.Handle,
//},
};
HttpServer httpServer =
new
HttpServer(8080, route_config);
Thread thread =
new
Thread(
new
ThreadStart(httpServer.Listen));
thread.Start();
}
catch
(Exception ex)
{
string
s = ex.Message;
string
t = ex.StackTrace;
// throw;
MessageBox.Show(s +
" \r\n "
+ t);
}
}
Reply
Answers (
3
)
GPA calculate program in c++
data loding time is more in LINQ with mvc C#