33 constexpr operator crow::black_magic::const_str()
const {
34 return crow::black_magic::const_str(
str);
37 constexpr operator ::std::string()
const {
38 return ::std::string(
str);
49 template <
typename ModelType,
typename Storage>
54 using PreprocessFunction = ::std::function< PreprocessFunctionType >;
59 using PostprocessFunction = ::std::function< PostprocessFunctionType >;
61 using InferenceRouteFunctionType = void(
const crow::request &, crow::response &, ModelType *);
62 using InferenceRouteFunction = ::std::function< InferenceRouteFunctionType >;
63 using RegularRouteFunctionType = void(
const crow::request &, crow::response &);
64 using RegularRouteFunction = ::std::function< InferenceRouteFunctionType >;
68 crow::App<crow::CORSHandler> _app;
69 PreprocessFunction _preprocess;
70 PostprocessFunction _postprocess;
84 PreprocessFunction preprocess,
85 PostprocessFunction postprocess,
86 ::std::string allowed_origins =
"*",
88 unsigned short port = 18080);
94 template <PathString Path>
101 template <PathString Path>
102 constexpr void add_regular_route(crow::HTTPMethod method, RegularRouteFunction route);
108 #include "CNum/Deploy/Deploy.tpp"
2d array abstraction
Definition Matrix.h:43
void start()
Start the backend.
Definition Deploy.h:95
constexpr void add_regular_route(crow::HTTPMethod method, RegularRouteFunction route)
Add a route that doesn't use a model.
Definition Deploy.h:87
constexpr void add_inference_route(crow::HTTPMethod method, InferenceRouteFunction route)
Add a route to the API that uses a model.
Definition Deploy.h:59
InferenceAPI(::std::string path, PreprocessFunction preprocess, PostprocessFunction postprocess, ::std::string allowed_origins="*", size_t n_models=20, unsigned short port=18080)
Constructor.
Definition Deploy.h:3
A pool of trained models.
Definition ModelPool.h:13
Tools for creating REST APIs.
constexpr size_t MAX_URL_LEN
The maximum length of a path for a route in the REST API.
Definition Deploy.h:14
constexpr PathString(const char(&s)[MAX_URL_LEN])
Definition Deploy.h:27
char str[MAX_URL_LEN]
Definition Deploy.h:25