这是一个使用Perl Net::Server 模块创建的简单流媒体服务器示例,它能够播放.flv文件。
首先,确保安装了Net::Server
模块,如果没有安装,可以使用CPAN来安装它:
运行 cpan Net::Server
下载安装 RHANDOM/Net-Server-2.014.tar.gz
或者 perl Makefile.PL
gmake install
然后,编写 http_flv_server.pl 文件 如下
#!/usr/bin/env perl
use strict;
use warnings;
use Net::Server;
use HTTP::Server::Simple::CGI;
use File::Basename;
use MIME::Types;
my $server = Net::Server->new(
host => '127.0.0.1',
port => 8080,
nodaemon => 1,
shutdown_only => 1,
);
$server->run();
sub handle_request {
my ($q) = @_;
my $filename = basename($q->url);
my $path = "/path/to/your/videos/$filename";
if (-e $path) {
$q->send_file(
path => $path,
type => 'video/x-flv',
# Optional