Skip to content
Snippets Groups Projects
Commit e7c208ae authored by echicken's avatar echicken :chicken:
Browse files

Treat command line argument as an alternate URL.

This allows for greater flexibility with the options, and the
possibility of querying your own (or some other) wttr server.
parent e844d66d
No related branches found
No related tags found
1 merge request!463MRC mods by Codefenix (2024-10-20)
......@@ -33,14 +33,10 @@ Contents
3) Customization
Please see https://wttr.in/:help for a list of options. You may pass any
of the 'Units' and 'View options' values to this script on the command
line to customize the output, for example:
Any arguments that you pass on the command line will be treated as an
alternate URL to query. For example:
Command Line ?wttr.js m0AFn
Command Line ?wttr.js https://wttr.in/?m0AFn
The default is 'AFn' for ANSI, no 'Follow' line, and narrow output.
Note that your command line argument will completely replace the default
parameters. You will probably want to specify 'A' and 'n' in addition to
your chosen values.
The default is URL is 'https://wttr.in/?AFn' for ANSI, no 'Follow' line,
and narrow output.
......@@ -8,10 +8,10 @@ function uReplace(str) {
}
function fetchWeather(addr) {
const qs = argc > 0 ? argv.join('') : 'AFn';
const qs = argc > 0 ? argv.join('') : 'https://wttr.in/?AFn';
const http = new HTTPRequest();
if (addr !== undefined) http.extra_headers = { 'X-Forwarded-For': addr };
const body = http.Get('https://wttr.in/?' + qs);
const body = http.Get(qs);
if (http.response_code !== 200) throw new Error('wttr.in response had status ' + http.response_code);
return body;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment