Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Activate json listing with an url param #19

Open
izissise opened this issue Oct 26, 2019 · 1 comment
Open

Activate json listing with an url param #19

izissise opened this issue Oct 26, 2019 · 1 comment

Comments

@izissise
Copy link
Owner

Some software prefer html listing (eg: kodi), it should be possible to ask for html listing with an url param

Failed try with nginx conf

server {
    listen 80;

    root /home/user/downloads;
    #location for json requests
    location ^~ /files/ {
        #PathOnYourHardDrive Last slash is important
        alias /home/user/downloads/;

        # Random id so nginx doesn't serve random html files
        index aaaaaaaaaaaaaaaaaa;
        autoindex on;
        set $index_format "json";
        if ( $arg_html = "1" ) { set $index_format "html"; }
        autoindex_format $index_format;
        autoindex_exact_size on;

        sendfile           on;
        sendfile_max_chunk 2m;
        tcp_nopush         on;
        tcp_nodelay        on;
        keepalive_timeout  65;

        # error_page 418 = @htmllisting;
        # if ( $arg_html = "1" ) { return 418; }
    }

    # location @htmllisting {
    #     alias /;
    #     autoindex on;
    #     autoindex_format html;
    #     autoindex_exact_size on;
    #
    #     sendfile           on;
    #     sendfile_max_chunk 2m;
    #     tcp_nopush         on;
    #     tcp_nodelay        on;
    #     keepalive_timeout  65;
    # }

    location / {
        root /var/www/files/;
        # Try files so nginx serves the root index for all paths
        try_files $uri $uri/ /index.html;

        sendfile           on;
        sendfile_max_chunk 2m;
        tcp_nopush         on;
        tcp_nodelay        on;
        keepalive_timeout  65;
    }
}
@izissise izissise changed the title Activate html listing with an url param Activate json listing with an url param Oct 16, 2024
@izissise
Copy link
Owner Author

Js code could support both

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant