Need some opinions on this LAMP or Python?

Discussion in 'Programming/Html' started by anticupidon, Aug 2, 2020.

  1. anticupidon

    anticupidon Ancient Guru

    Messages:
    5,780
    Likes Received:
    2,203
    GPU:
    Polaris/Vega/Navi
    Hello gurus!
    Got back on IT field and one of the things I was asked to do as a side project is to show a daily menu for a takeaway restaurant.
    I have a big TV where the information will be showed and they want to choose from a tablet or a PC the menu list (3,4 items) and display those on the TV screen.
    My approach is;
    Get a Raspberry Pi. Get LAMP stack install on it.
    Create a database, a PHP script which will dinamically display a webpage on the TV screen.

    Now, maybe Python script will be simpler?
    Anyone who made something similar could chime in?
    Thanks in advance,

    Cheers
     
    Deleted member 213629 likes this.
  2. sverek

    sverek Ancient Guru

    Messages:
    6,073
    Likes Received:
    2,953
    GPU:
    NOVIDIA -0.5GB
    A bit late to reply to, but here we go. Python could be decent by showing graph and data, there lots of libraries to achieve it.
    However, if you want highly customizable UI, HTML is a way to go.

    If you plan to run it for a while, Raspberry Pi might not be the most stable choice. It might crash due to heat, SD card read issues or other factors. Great to mess with at home, not really great at deployment in my experience.

    Maybe mini desktop PC or even better laptop could be safer choice. Easy to restart if something goes wrong and can be operated by your customer with a simple user-manual (so you don't have to fix it everytime it fails to start).

    I'd go with LAMP, design DB ER, make sure it fits customers needs and then write server and client applications.

    Application could be something like below:

    Customer inputs order (HTML Form) -> send request to PHP server, add database record -> Big TV application will run on HTML and JS script running in background to fetch latest DB data and display it.

    So we have 2 browsers (customer input and TV screen). Tablet can run of laptop Wifi network, therefore all JS requests would be within LAN.

    Good to see you back in IT, we are all sane here :D
    Best of luck! If you need any help, let me know!
     
    Deleted member 213629 likes this.
  3. anticupidon

    anticupidon Ancient Guru

    Messages:
    5,780
    Likes Received:
    2,203
    GPU:
    Polaris/Vega/Navi
    @sverek , Thank you so much for your time to answer and provide insight and advice.
    I concur on the Raspberry, it is a wonderful platform for hobbyist, but not quite for deployment on a production environment.
    So my budget allowed to buy a Intel NUC with an SSD and 4 GB of RAM.
    Has 2 HDMI ports and can be set up in the BIOS which is which and later on assigned to a VNC viewer or app. This is of importance.

    Now, for the time being and for commodity sake ( and also to have something meanwhile) I will install Ubuntu server/core with LAMP and install WordPress.
    Parallel with that I've started to create a draft of the web app needed.
    Problem is that are so many tasks at hand and for now, I am the only one IT guy here. I can give some time to this taks, but down the road things will work by itself.
    I asked for a little patience for that and WordPress should do 90% of what is needed.
     
  4. sverek

    sverek Ancient Guru

    Messages:
    6,073
    Likes Received:
    2,953
    GPU:
    NOVIDIA -0.5GB
    WordPress would be a good start, less headache creating website from a scratch.

    Come to think of, if menu is not updating constantly, DB (and even PHP) might not be needed at the start.
    You can just create a few HTML pages, (or even simpler .png images with photoshop) with different menu combinations.
    So, simply show full screen browser with static HTML or Image on the TV screen.
    Restaurant owner will choose which HTML to load, depending on menu and it will displayed on big TV screen. (You may create simple program, that opens target HTML or Image for menu combination)

    Example of menu combinations of items with simple html or image files:

    Display html menu with items 1,2,3,4 ->
    menu_1_2_3_4.html

    Display html menu with items 1,2,4 ->
    menu_1_2_4.html

    Display image menu with items 1,2,4 ->
    menu_2_4.png

    etc....

    I'd just create patterns, without bothering with DB or PHP.

    My point is to start simple, deliver sooner, gain momentum and adjust with your customer needs.
    Maybe DB or PHP won't be needed at all... just a few tricks to cover the requirements.

    Would be shame to spend 100 hours on an application that won't be fully utilized.
     
    anticupidon likes this.

  5. anticupidon

    anticupidon Ancient Guru

    Messages:
    5,780
    Likes Received:
    2,203
    GPU:
    Polaris/Vega/Navi
    Well, my intuition didn't fail me. I thought precisely at the same method.
    Yes, sounds ridiculous after you wrote it but @sverek , my employer was lulled by the WordPress endless possibilities and forgot about developing our own solution.
    Why reinvent the wheel?
    But this is a temporary solution and a simple one. Down the road we can complicate things as we can, but for now Wordpress can save the day.
    Will test tomorrow my page and see if anything goes wrong. Murphy's law.
    Cheers !
     
  6. anticupidon

    anticupidon Ancient Guru

    Messages:
    5,780
    Likes Received:
    2,203
    GPU:
    Polaris/Vega/Navi
    Some updates:
    Got the system hooked to the TV and now it displays a webpage. The idea is to be able to change it from outside.
    Question: I need a VPN server inside the LAN, ports forwarded in the router, DynDNS to external IP and from home log into the VPN server?
    Or a Linode cloud VPN and make all the adjustments?
    I got this right?
     
  7. sverek

    sverek Ancient Guru

    Messages:
    6,073
    Likes Received:
    2,953
    GPU:
    NOVIDIA -0.5GB
    Well that was fast :)

    I don't have much experience with VPN. If restaurant owner has full access to network and router, installing OpenVPN and accessing the LAN to deploy webpage makes sense.

    I think issue is, browser have to refresh webpage to display the new version, so you probably would need remote desktop to do it.
    However, if you able to run remote desktop, I don't think there need for VPN, since you can download your new webpage (from secure cloud, etc...) with remote desktop and apply it.
    I think there is remote Ubuntu desktop available, however I am not sure how well it works.
    (perhaps using SSH can accomplish deployment task as well)

    Just have to make sure TV screen doesn't show you working with deployment during remote desktop session. (Would be best to perform it before/after restaurant working hours)

    Anyway, if your customer doesn't have static IP address, you will need to setup DynDNS either way, to figure out its IP address and connect to it.
     
  8. anticupidon

    anticupidon Ancient Guru

    Messages:
    5,780
    Likes Received:
    2,203
    GPU:
    Polaris/Vega/Navi
    Yes, the real problem is to refresh the webpage to update to new changes. I can message someone to simply press F5, but I always remember that even simplest things for non-literate computer people can be a huge pain in the back.
    So remote desktop it is.
    I installed RealVNC viewer and made de facto de 2 F auth method. Will use a secure SSH tunnel to connect trough with VNC viewer, as in itself that service is not so secure. And yes, set up DynDNS in the Ubuntu machine and forwarding the port.
    But the RealVNC made me understand that registering to their service with a personal account that can make it happen, to connect to a remote machine without the hassle. I think that they use reverse NAT. But I may be wrong .
     
  9. anticupidon

    anticupidon Ancient Guru

    Messages:
    5,780
    Likes Received:
    2,203
    GPU:
    Polaris/Vega/Navi
    Some updates.
    After a few days pulling my hair out just to configure RealVNC. I know, it was supposed to be simple, following some steps from a guide.
    Did that only to connect over a SSH secure tunnel and get a grey screen.
    I'll explain. Normally, when you VNC into a machine, you are supposed to land on a desktop and within that GUI you do all you need to do. But there is a bug haunting VNC connections, you succesfully connect to the machine, but you are getting a big X and a grey o black screen. Just google VNC grey screen...you'll understand quickly.
    So, went back and installed X2go and instant succes. First, establish a SSH connection and then start the X2go client and land on the desktop enviroment I choose, LXDE, XFCE, etc...

    Still, there was the remote connexion problem. The decision to buy the top tier router is not yet made, and the ISP router doesn't allow VPN , you need to pay for their solution.
    So, in order to remotely acces my machine, without touching the port forwarding and not exposing them to the internet i went with Zerotier.
    Defined my virtual network, installed Zerotier on all machines and from the control panel I allowed each machine specifically to that network. I can remotely conect to any machine within that virtual LAN and no ports are open. Free and open source on top of that.

    I have yet to design a web app (AJAX,Javascript ) to work with my database and Wordpress page, but small progess was made.
     
  10. anticupidon

    anticupidon Ancient Guru

    Messages:
    5,780
    Likes Received:
    2,203
    GPU:
    Polaris/Vega/Navi
    Made some progess, but slow.
    Found this on the W3School page:

    And this code snippet, the most closer to what I need:

    https://www.w3schools.com/js/js_ajax_database.asp

    So, it is just create a data base ,runs a query against this database, and returns the result in an HTML table:

    Until now I think I can follow.
    Question:
    If anyone wants to modify the desired data from the table, should have a dropdown menu, who retrieves the choices from the same database. But I would like to do this on a separate webpage, window. Only the final result to be shown on the main screen.
    Anyone?
     

  11. anticupidon

    anticupidon Ancient Guru

    Messages:
    5,780
    Likes Received:
    2,203
    GPU:
    Polaris/Vega/Navi
    Hello gurus!
    It's been a while since I dabble with php and MySQL.
    Did some login form and user registration and a welcome/dashboard.
    Now, in the welcome page i shave the php
    Code:
    <?php
    // Initialize the session
    session_start();
     
    // Check if the user is logged in, if not then redirect him to login page
    if(!isset($_SESSION["loggedin"]) || $_SESSION["loggedin"] !== true){
        header("location: login.php");
        exit;
    }
    ?>
    It works as it should . validating the user.
    Now, my question is the following:
    In the dashboard/welcome I want to allow the users to modify a menu or to add something in the menu which holds the menu items. In the same dashboard menu, how can I declare the other php statement confirming the connection to the item's database? can I have 2 separate pho statements in the same page or do I have to do something else?
     

Share This Page