basic alpr interface
This commit is contained in:
36
src/rest/index.js
Normal file
36
src/rest/index.js
Normal file
@@ -0,0 +1,36 @@
|
||||
import express from 'express';
|
||||
import http from 'http';
|
||||
import Hack from '../components/Hack';
|
||||
|
||||
const PORT = 3000;
|
||||
|
||||
class BasicApi {
|
||||
app;
|
||||
server;
|
||||
hack;
|
||||
|
||||
constructor() {
|
||||
this.app = express();
|
||||
this.server = http.createServer(this.app);
|
||||
this.hack = new Hack();
|
||||
}
|
||||
|
||||
init() {
|
||||
this.server.listen(PORT, () => {
|
||||
console.log(`Server running at port ${PORT}`);
|
||||
});
|
||||
this.registerEndpoints();
|
||||
}
|
||||
|
||||
registerEndpoints() {
|
||||
this.app.get('/:plate', async ({ params }, response) => {
|
||||
const { plate } = params;
|
||||
await this.hack.init(plate);
|
||||
response
|
||||
.status(200)
|
||||
.send(this.hack.getCar());
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export default BasicApi;
|
||||
Reference in New Issue
Block a user