class ApiController extends Controller
{
public function regist(Request $request)
{
$this->eatingManagement->registTemplate($request->contents);
return response()->json();
}
class EatingManagementRepository
{
public function registTemplate($ids)
{
$records =EatingHistoryItem::whereIn('id', $ids )->get();
foreach($records as $record)
{
$model = new EatingTemplateItem();
foreach($this->templateParamNames as $name)
{
$model->$name = $record[$name];
}
$model->save();
$record->delete();
}
}
def do_GET(self):
parsed = urlparse(self.path)
if parsed.path == '/Streaming':
global lasttime
lasttime = time.time()
enc = sys.getfilesystemencoding()
プレビュー画をリクエストがあったら、その時間を記憶しておきます。
def videoCapture():
global capture
global out
while capture:
nowtime = time.time()
if nowtime - lasttime > 10:
capture = False
out.release()
out = None
break
_, img = cap.read()
out.write(img)