두 번 실행되는 Flask 개발 서버: 이유 공개
Flask 개발 서버는 코드가 변경될 때마다 애플리케이션 재시작을 처리합니다. . 이 기능은 Werkzeug 라이브러리의 restart_with_reloader() 함수에 의해 제공됩니다.
이 함수는 하위 프로세스를 생성하고 subprocess.call()을 사용하여 스크립트를 다시 실행합니다. 결과적으로 원본 스크립트와 하위 프로세스 모두 다시 시작 메시지를 각각 한 번씩 인쇄하여 이중 인쇄 동작이 관찰됩니다.
리로더 비활성화
이 동작을 제거하려면 , use_reloader를 False로 설정하여 리로더를 비활성화합니다:
app.run(port=4004, debug=config.DEBUG, host='0.0.0.0', use_reloader=False)
또는 플라스크 실행을 사용할 수도 있습니다 --no-reload 플래그가 있는 명령:
FLASK_DEBUG=1 flask run --no-reload
리로더 프로세스 감지
werkzeug.serving.is_running_from_reloader() 함수를 사용하여 하위 프로세스를 감지합니다. :
from werkzeug.serving import is_running_from_reloader if is_running_from_reloader(): print(f"################### Restarting @ {datetime.utcnow()} ###################")
사용 @app.before_first_request 데코레이터
모듈 전역을 설정해야 하는 경우 @app.before_first_request 데코레이터 사용을 고려하세요.
@app.before_first_request def before_first_request(): print(f"########### Restarted, first request @ {datetime.utcnow()} ############")
이 데코레이터는 다시 로드할 때마다 한 번씩 함수를 실행합니다. 첫 번째 요청이 있을 때 made.
참고:
포킹 또는 하위 프로세스를 사용하여 요청을 처리하는 전체 규모 WSGI 서버에서는 각 하위 프로세스에 대해 before_first_request 핸들러가 호출될 수 있습니다.
위 내용은 내 Flask 개발 서버가 두 번 실행되는 것처럼 보이는 이유는 무엇입니까?의 상세 내용입니다. 자세한 내용은 PHP 중국어 웹사이트의 기타 관련 기사를 참조하세요!

Pythonusesahybridmodelofilationandlostretation : 1) ThePyThoninterPretreCeterCompileSsourcodeIntOplatform-IndependentBecode.

Pythonisbothingretedandcompiled.1) 1) it 'scompiledtobytecodeforportabilityacrossplatforms.2) thebytecodeisthentenningreted, withfordiNamictyTeNgreted, WhithItmayBowerShiledlanguges.

forloopsareusedwhendumberofitessiskNowninadvance, whilewhiloopsareusedwhentheationsdepernationsorarrays.2) whiloopsureatableforscenarioScontiLaspecOndCond

pythonisnotpurelynlogreted; itusesahybrideprophorfbyodecodecompilationandruntime -INGRETATION.1) pythoncompilessourcecodeintobytecode, thepythonVirtualMachine (pvm)

ToconcatenatelistsinpythonwithesameElements, 사용 : 1) OperatorTokeEpduplicates, 2) asettoremovedUplicates, or3) listComperensionForControlOverDuplicates, 각 methodHasDifferentPerferformanCeanDorderImpestications.

PythonisancerpretedLanguage, 비판적 요소를 제시하는 PytherfaceLockelimitationsIncriticalApplications.1) 해석 된 언어와 같은 thePeedBackandbackandrapidProtoTyping.2) CompilledlanguagesLikec/C transformt 해석

useforloopswhhenmerfiterationsiskNownInAdvance 및 WhileLoopSweHeniTesslationsDepoyConditionismet whilEroopsSuitsCenarioswhereTheLoopScenarioswhereTheLoopScenarioswhereTheLoopScenarioswhereTherInatismet, 유용한 광고 인 푸트 gorit


핫 AI 도구

Undresser.AI Undress
사실적인 누드 사진을 만들기 위한 AI 기반 앱

AI Clothes Remover
사진에서 옷을 제거하는 온라인 AI 도구입니다.

Undress AI Tool
무료로 이미지를 벗다

Clothoff.io
AI 옷 제거제

Video Face Swap
완전히 무료인 AI 얼굴 교환 도구를 사용하여 모든 비디오의 얼굴을 쉽게 바꾸세요!

인기 기사

뜨거운 도구

Atom Editor Mac 버전 다운로드
가장 인기 있는 오픈 소스 편집기

SublimeText3 영어 버전
권장 사항: Win 버전, 코드 프롬프트 지원!

드림위버 CS6
시각적 웹 개발 도구

에디트플러스 중국어 크랙 버전
작은 크기, 구문 강조, 코드 프롬프트 기능을 지원하지 않음

DVWA
DVWA(Damn Vulnerable Web App)는 매우 취약한 PHP/MySQL 웹 애플리케이션입니다. 주요 목표는 보안 전문가가 법적 환경에서 자신의 기술과 도구를 테스트하고, 웹 개발자가 웹 응용 프로그램 보안 프로세스를 더 잘 이해할 수 있도록 돕고, 교사/학생이 교실 환경 웹 응용 프로그램에서 가르치고 배울 수 있도록 돕는 것입니다. 보안. DVWA의 목표는 다양한 난이도의 간단하고 간단한 인터페이스를 통해 가장 일반적인 웹 취약점 중 일부를 연습하는 것입니다. 이 소프트웨어는