mirror of
https://github.com/chubin/wttr.in.git
synced 2024-10-05 09:52:13 +02:00
refactor: move out plain text agents to separate list.
This commit is contained in:
parent
5a7f09d8b9
commit
afc8eafd61
13
bin/srv.py
13
bin/srv.py
@ -222,11 +222,20 @@ def send_favicon():
|
||||
@app.route("/")
|
||||
@app.route("/<string:location>")
|
||||
def wttr(location = None):
|
||||
plain_text_agents = [
|
||||
"curl",
|
||||
"httpie",
|
||||
"lwp-request",
|
||||
"wget",
|
||||
]
|
||||
|
||||
user_agent = request.headers.get('User-Agent').lower()
|
||||
|
||||
html_output = True
|
||||
if 'curl' in user_agent or 'wget' in user_agent or 'httpie' in user_agent or 'lwp-request' in user_agent:
|
||||
if any(agent in user_agent for agent in plain_text_agents):
|
||||
html_output = False
|
||||
else:
|
||||
html_output = True
|
||||
|
||||
|
||||
if location == ':help':
|
||||
help_ = show_help()
|
||||
|
Loading…
Reference in New Issue
Block a user