Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Web interface for C++ application  (Read 8231 times)

0 Members and 1 Guest are viewing this topic.

mickes27

  • Newbie
  • *
  • Posts: 14
    • View Profile
    • Email
Web interface for C++ application
« on: November 07, 2018, 10:34:15 pm »
Hello. I have a program written in C++, but at this moment it works in console. I was using SFML for making graphic interface previously, but this time I want to try something new. My program is suppose to work on embedded system (like Raspberry Pi), so I won't have display screen for it. Instead of that, I wanted to make some web browser interface for it. User has to type Raspberry Pi IP in own browser, along with port (for example 192.168.48.5:8888) and than he should see the simple interface (not much, just a few buttons). After clicking button, certain things should happen in C++ program. Am I able to achieve that with SFML? Where should I search? Is it CGI/REST API?

Example: UV4L with it's webRTC server (it has interface I am looking for - https://i.stack.imgur.com/w5Yhz.png?fbclid=IwAR1UexTVjdM8rDe5O8apC6_lULzVMJsT9rL1qDk9mAjyEPqnVOFvBjZ5PyA)

Thanks for help
« Last Edit: November 07, 2018, 11:15:19 pm by mickes27 »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
Re: Web interface for C++ application
« Reply #1 on: November 08, 2018, 12:08:02 am »
SFML only provides a HTTP client and TCP Sockets, as such writing your own server with SFML isn't exactly trivial, as you need to implement the whole HTTP protocol your self using a TCP socket.
Alternatively, you may find some (header-only) libraries that handle HTTP parsing for you.

You can start off by reading the networking tutorial, API documentation and FAQ. :)
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

mickes27

  • Newbie
  • *
  • Posts: 14
    • View Profile
    • Email
Re: Web interface for C++ application
« Reply #2 on: November 08, 2018, 09:30:29 pm »
So you think it should be better to use some other library?

billarhos

  • Newbie
  • *
  • Posts: 17
    • View Profile
Re: Web interface for C++ application
« Reply #3 on: November 08, 2018, 09:50:41 pm »
You can try chrome cef
https://en.wikipedia.org/wiki/Chromium_Embedded_Framework

you can register javascript functions and talk via your c++ code

do not forget to built cef without sandbox security
« Last Edit: November 08, 2018, 09:52:14 pm by billarhos »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
Re: Web interface for C++ application
« Reply #4 on: November 08, 2018, 10:52:39 pm »
That's a bit drastic to jump from a simple HTTP server to full-blown browser engine, also a bit apples and oranges. ;)

SFML certainly isn't the best tool if your goal is to create a server. It can be done, but it will require a lot of work or use of third-party libraries.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Web interface for C++ application
« Reply #5 on: November 09, 2018, 06:38:40 am »
For example, Wt does what you want.
Laurent Gomila - SFML developer

mickes27

  • Newbie
  • *
  • Posts: 14
    • View Profile
    • Email
Re: Web interface for C++ application
« Reply #6 on: November 09, 2018, 08:40:41 am »
Thank you