|
Hello everyone,
I've a general (beginner) question about web programming. I'd like to display content graphically on a web page whose data is generated by a permanently running C++ program (in Qt).
For me, the first question is, which technologies do I need for this?
In my naivety I would now assume that the Qt program for generating data would have to run on a server with a fixed IP. It would also have to be able to connect via sockets.
The website would use a PHP script running on a web server, so that it would somehow communicate with the Qt program?
Thanks a lot for any help!
|
|
|
|
|
hello all alone,
The C ++ executable application under Qt must save its data produced in a BDD Database
(or a file) on the web server side; and the web application (also running on the server), called
by the remote client web browser, will read these data in the DB (or in the file) for then
interpret / decode them then display them as graphics in the client browser.
For example in PHP, there are functions to access the mySQL database.
Under Qt, you can also access mySQL databases in C ++.
Other solutions :
- use (or design) a suitable PHP extension,
- call the executable C ++ program from PHP with the PHP function shell_exec ()
( see an example of "Serial COM port access in PHP" here:
https://radiovibrations.com/techblog.php?i=10 )
Cordially.
|
|
|
|
|
Hi All,
I am using Kendo Grid in my application and need to implement better paging feature, sorting, Filtering,Groping and customization. Please share if anyone as implemented this feature already.
Thanks,
Sagar Pallavi
|
|
|
|
|
Hi Everyone, I'm new here
|
|
|
|
|
|
Hello,
I am looking for software where I can code and alter my Wordpress site. Using a mac, tried Adobe Dreamweaver, didnt get far. Recommandations please? Thank you in advance!
|
|
|
|
|
|
Why do we need them? What can't I just do this:
public class MyController : ApiController
{
public void DoSomething(MyEntity entity)
{
MyBL myBL = new MyBL();
myBl.DoSomethingElse(entity);
}
}
Why do I need the Http verbs to do this?
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
|
|
|
|
|
You generally want to avoid letting GET requests modify state. They should be idempotent to avoid problems with pre-fetching and caching.
Beyond that, you can use whatever verbs you like. But REST services follow a specific pattern:
Representational state transfer - Wikipedia[^]
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
OK. So said anything about state? What's stopping me from doing this:
public class MyController : ApiController
{
[HttpGet]
public void DoSomething(int id)
{
MyBL myBL = new MyBL();
myBl.DeleteARecord(Id);
}
}
I'm calling a method to delete a record in a method marked as [HttpGet].
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
|
|
|
|
|
As I said, you should avoid doing that. Your GET method could be called multiple times. It could be pre-fetched. It could be cached.
GET requests should be idempotent, and should not affect state.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Every http request has a verb, that's just how http works, the verb lets the service know what action is being done, the theory being that you can use the same url to do different things. If you have the following endpoint
/product/5
then calling it with GET will return product 5's data, calling it with DELETE will delete product 5 and so on. Because all requests have a verb you have to tell .net which verbs are valid for your method.
|
|
|
|
|
I guess I don't understand why you even need to mark up the method. What if I did this:
public class MyController : ApiController
{
[HttpGet]
public void DoSomething(int id)
{
MyBL myBL = new MyBL();
myBl.DeleteARecord(Id);
}
}
I've marked the method with [HttpGet], yet called a Delete method on the BL.
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
|
|
|
|
|
If you do that it will fail with a 404 as the method doesn't allow that verb.
|
|
|
|
|
Why not? There's nothing there to indicate what is does. I could name the BL method "BeHappy" and it would still run
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
|
|
|
|
|
It won't work because you haven't marked it [HttpDelete]
|
|
|
|
|
That still doesn't answer the question. The word 'delete' doesn't even exist in the method. What's stopping me from calling it?
I've called Web API methods before like TaxController's CalculateTax method. There's no HttpGet, HttpPut, HttpPost, or HttpDelete there, yet the method works.
So, again, what purpose do the verbs serve?
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
|
|
|
|
|
Kevin Marois wrote: The word 'delete' doesn't even exist in the method. What's stopping me from calling it?
If you put a non-delete verb attribute on it then the framework will stop you calling it, it will return a 404. .net has two ways of associating methods with verbs, one is the explicit adding of the attributes which will restrict what can route to that action. It also follows a naming convention so you can put the verb at the start of the action name, so GetProduct, DeleteProduct etc and .net will use that to route your calls to the right method by matching the verb with the action prefix. You can choose to follow neither convention and use bespoke names and no verb attributes and the routing will (I assume) work on the action name only.
So the purpose they serve is that if you want to following proper semantic api conventions where you route your calls to actions based on the verb then the HttpXXX attributes allow you to implement that convention if you don't want to use the names themselves to route your methods.
|
|
|
|
|
F-ES Sitecore wrote: If you put a non-delete verb attribute on it then the framework will stop you calling it, it will return a 404.
This is what's confusing to me. I have a Web API with NO verbs on it, and I can call it from my WPF app just fine. That's what got me posting this... what's the point of the verbs if I can create and call methods without them?
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
|
|
|
|
|
Supposedly if there are no verbs applied it defaults to HttpPost, so even though you didn't specify a verb, one does exist.
|
|
|
|
|
It won't fail because he's suggesting calling that with HttpGet as the verb. Syntactically it's correct, but is not good practice.
I guess part of the answer is that historically, the HTTP verb played a more important part. Languages / frameworks were less flexible (or stricter?). There remain some practicalities - if you want to upload a 50Mb file, you don't want to use HttpGet because that would require the payload to be in the URL, and Http doesn't support URLs of that length. Your webserver may handle different verbs very differently, but where we're using IIS we can have ASP.Net handle different verbs - or ignore certain verbs - just how we want. For example, by default, IIS won't let you invoke a .ASMX webservice via HttpGet - but you can make a trivial change in web.config to allow it.
From RFC2616[^], part of the HTTP1.1 definition:
Quote: In particular, the convention has been established that the GET and HEAD methods SHOULD NOT have the significance of taking an action other than retrieval. These methods ought to be considered "safe". This allows user agents to represent other methods, such as POST, PUT and DELETE, in a special way, so that the user is made aware of the fact that a possibly unsafe action is being requested. Interestingly, the implication is that the end user is aware of the HTTP verbs being used in an interaction - again, a throwback to a time when internet use was the preserve of techs working at protocol level.
In short, then, the answer to the original question is simply: it's convention.
|
|
|
|
|
DerekT-P wrote: It won't fail
It will. The verbs are used as part of the routing subsystem which maps requests to actions. Requesting an action called "DoSomething" that is marked as HttpDelete with a GET request is (to the routing system) no different to requesting an action called "DoSomethingElse" when no action with that name exists. If it can't map the request to an action you get a 404.
|
|
|
|
|
Kevin said: public class MyController : ApiController
{
[HttpGet]
public void DoSomething(int id)
{
MyBL myBL = new MyBL();
myBl.DeleteARecord(Id);
}
}
I've marked the method with [HttpGet], yet called a Delete method on the BL. "DoSomething" is marked up for HttpGet and he says he's calling it with HttpGet . In his method DoSomething he calls a business layer method myBL.DeleteARecord(Id) but for all we know that is just counting apples.
OR - and this may be the case, I don't do MVC so maybe it's a .Net restriction (as opposed to an HTTP restriction) - will it not allow you to have a void method decorated with HttpGet ? (In which case it shouldn't even compile).
There are two parts to an answer to Kevin's question - firstly, why does HTTP need verbs; then secondly, why does ASP.Net need to reference them? From my WebForms / web service background, I've never had to deal with HTTP verbs, other than (in some cases) allowing .ASMX services to be called from a GET request (which was done purely for the benefit of a 3rd party, to make testing simpler for them). Re-reading the original post, I think Kevin's more concerned with why ASP.Net MVC needs the markup, to which the answer is that it's used for mapping the request to the method.
|
|
|
|
|
DerekT-P wrote: "DoSomething" is marked up for HttpGet and he says he's calling it with HttpGet . In his method DoSomething he calls a business layer method myBL.DeleteARecord(Id) but for all we know that is just counting apples.
Correct, I misread the post and have posted an update
|
|
|
|
|
Looking back I misread this so I can see where the confusion has come from. I thought you said you were calling it with a DELETE verb which is why I said it wouldn't work, that was my mistake I didn't realise you were saying that you were calling a delete method in the code. So yes you're right, that code would work, but you then enter the semantic convention debate again and could say that if your method's purpose is to delete something it should be marked with HttpDelete, and then you wouldn't be able to call it with GET.
Apologies for the confusion, that was a mistake on my part
|
|
|
|