W
W
Wadik2014-06-27 16:04:44
Nginx
Wadik, 2014-06-27 16:04:44

How to count the number of Internet radio listeners?

There is an internet radio directory (an ordinary directory, nothing special about it).
I would like to introduce a rating by the number of daily listening to radio stations. The question is how to calculate the audience?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
H
HerrNiemand, 2016-02-27
@HerrNiemand

Here's what I did.
I broke $uriit into separate words with regex.
That is, /data/countrieswe get from ['data', 'countries']
Then I simply redirected to $uri, and did try_files $uri$2.json $uri/$2.json =404;, which actually takes the second argument ( $2), and adds to $uri, at the end adds .jsonand tries the file. If it finds it, it gives it back, if not, 404.
The whole code:

location /data {
        rewrite (\w+) $uri break;
        try_files $uri$2.json $uri/$2.json =404;
}

Thanks everyone for the advice. *)
Special thanks to Mr. Alexey POS_troi for the opportunity to poke. gee gee gee

T
TyzhSysAdmin, 2016-02-25
@POS_troi

Head-on :)

location /data/test/ {
    index test.json;
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question