在 crow 中获取非整数(字符串)url 资源 ID
Fetch non-int (string) url resource-id in crow
如何在 C++ 中获取非整数资源 ID crow。我无法添加路线
CROW_ROUTE(app, "/uid/<std::string>")
或 CROW_ROUTE(app, "/uid/<char*>")
因为编译失败。 examples 没有这种情况。我试过了
int main() {
crow::SimpleApp app;
CROW_ROUTE(app, "/uid/*").methods("GET"_method)
([](const crow::request& req){
return "hello";
});
CROW_ROUTE(app, "/uid/<int>").methods("GET"_method)
([](const crow::request& req, int id){
return std::to_string(id);
});
app.port(8888).run();
}
但是他们都没有(虽然正确地)拦截了 GET /uid/uid_123 HTTP/1.1
(资源是一个字符串 "uid_123"
)
对于下面的python代码,我想在c++ crow库中实现它
from flask import Flask
app = Flask(__name__)
@app.route("/uid/<path:path>")
def hello1(path):
print ("it is path is ", path)
return "user id is -" + path
if __name__ == "__main__":
app.run(host="0.0.0.0", port=8888)
是否有解决上述问题的方法?
如何在 C++ 中获取非整数资源 ID crow。我无法添加路线
CROW_ROUTE(app, "/uid/<std::string>")
或 CROW_ROUTE(app, "/uid/<char*>")
因为编译失败。 examples 没有这种情况。我试过了
int main() {
crow::SimpleApp app;
CROW_ROUTE(app, "/uid/*").methods("GET"_method)
([](const crow::request& req){
return "hello";
});
CROW_ROUTE(app, "/uid/<int>").methods("GET"_method)
([](const crow::request& req, int id){
return std::to_string(id);
});
app.port(8888).run();
}
但是他们都没有(虽然正确地)拦截了 GET /uid/uid_123 HTTP/1.1
(资源是一个字符串 "uid_123"
)
对于下面的python代码,我想在c++ crow库中实现它
from flask import Flask
app = Flask(__name__)
@app.route("/uid/<path:path>")
def hello1(path):
print ("it is path is ", path)
return "user id is -" + path
if __name__ == "__main__":
app.run(host="0.0.0.0", port=8888)
是否有解决上述问题的方法?