Search code examples
perlwebmojolicious

How do i use Hypnotoad as a http server


I am trying to use hypnotoad server to serve some static html pages. What configuration do i need to do or where shall i keep my static html files for hypnotoad to pick them.

Thanks!!


Solution

  • IIRC the servers provided by Mojolicious, of which Hypnotoad is one, serve static HTML from a folder named public. All you should need is the most basic of applications to start the server. I this should be enough for simple use,

    #!/usr/bin/env perl
    use Mojolicious::Lite;
    
    # needed to setup the usual index.html landing
    any '/' => sub {
      shift->render_static('index.html');
    };
    
    app->start;
    

    and run with hypnotoad myapp.pl (assuming this script is saved as myapp.pl and is in the same location as the public folder).