假设以下路由访问xml文件以使用给定的xpath(?key =)替换特定标记的文本:
@app.route('/resource', methods = ['POST'])
def update_text():
# CODE
Run Code Online (Sandbox Code Playgroud)
然后,我会像这样使用cURL:
curl -X POST http://ip:5000/resource?key=listOfUsers/user1 -d "John"
Run Code Online (Sandbox Code Playgroud)
xpath expreesion listOfUsers/user1应该访问标记<user1>以将其当前文本更改为"John".
我不知道如何实现这一点,因为我刚刚开始学习Flask和REST,我找不到任何关于这个具体案例的好例子.此外,我想使用lxml来操作xml文件,因为我已经知道了.
有人可以帮助并提供一个指导我的例子吗?
我一直在努力理解为什么某些 HTTP 端点为“probe_success”和“probe_http_status_code”返回“0”,同时完全能够通过curl获得“有效”响应。
例子:curl -s "localhost:9115/probe?target=http://linux.org&module=http_2xx" | grep -v '^#'
输出:
probe_dns_lookup_time_seconds 0.003712821
probe_duration_seconds 0.212811871
probe_failed_due_to_regex 0
probe_http_content_length 0
probe_http_duration_seconds{phase="connect"} 0.002263513
probe_http_duration_seconds{phase="processing"} 0.196389853
probe_http_duration_seconds{phase="resolve"} 0.006723945
probe_http_duration_seconds{phase="tls"} 0
probe_http_duration_seconds{phase="transfer"} 2.6001e-05
probe_http_redirects 1
probe_http_ssl 0
probe_http_status_code 0
probe_http_version 0
probe_ip_protocol 4
probe_success 0
Run Code Online (Sandbox Code Playgroud)
这是工作定义:
- job_name: 'blackbox'
scrape_interval: 30s
metrics_path: /probe
params:
module: [http_2xx]
static_configs:
- targets:
- http://linux.org
relabel_configs:
- source_labels: [__address__]
regex: '(.*)(:80)?'
target_label: __param_target
- source_labels: [__param_target]
regex: '(.*)'
target_label: instance
replacement: '${1}'
- source_labels: []
regex: '.*' …Run Code Online (Sandbox Code Playgroud) 只有两个问题:
这是我尝试安装 Slack 时的输出。
$ sudo dpkg -i slack-desktop-4.12.2-amd64.deb
Selecting previously unselected package slack-desktop.
(Reading database ... 155664 files and directories currently installed.)
Preparing to unpack slack-desktop-4.12.2-amd64.deb ...
Unpacking slack-desktop (4.12.2) ...
dpkg: dependency problems prevent configuration of slack-desktop:
slack-desktop depends on libappindicator3-1; however:
Package libappindicator3-1 is not installed.
dpkg: error processing package slack-desktop (--install):
dependency problems - leaving unconfigured
Processing triggers for desktop-file-utils (0.26-1) ...
Processing triggers for mailcap (3.68) ...
Errors were encountered while processing:
slack-desktop
Run Code Online (Sandbox Code Playgroud)
然后我尝试安装依赖项
$ sudo …Run Code Online (Sandbox Code Playgroud) 我在一行中有以下For循环:
var = ''.join('%02x' % ord(b) for b in string_var)
Run Code Online (Sandbox Code Playgroud)
如何在常规for循环中显示?
python ×3
lxml ×2
debian ×1
flask ×1
for-loop ×1
prometheus ×1
prometheus-blackbox-exporter ×1
rest ×1
xml ×1
xpath ×1