소스를 보면, request 모듈과 escape 모듈을 사용하셨는데...
사전에 해당 모듈 설치하셨는지 확인해 보세요.
만약 설치하지 않았다면
pip install requests 와
pip install escape 를 실행해서 설치해 보세요.
[내 pc에서 홈페이지 운영하기 동영상 보고 문의드립니다의 답글] ----------------------------------------------------------------
느지막히 파이썬을 공부하려고 해서 유튜브에서 동영상을 보고 직접 실행하다 보니 마무리가 되지 않고 에러가 떠서
문의를 드립니다.처음 실행에서는 파이썬 최신버전이 아닌듯 해서 최신버전으로 다시 설치하고 실행을 했습니다.
lask를 설치하고 start.py를 만들어서 run을 하니까 아래의 에러 화면이 나오는데 원인이 무엇인지
파악을 하기 어렵네요^^
---참고로 flask 설치부터 모두 캡쳐했습니다---
(homepage2) C:\pytheon_myproject\homepage2\Scripts>pip install flask
Collecting flask
Using cached Flask-2.3.2-py3-none-any.whl (96 kB)
Collecting Werkzeug>=2.3.3 (from flask)
Using cached Werkzeug-2.3.6-py3-none-any.whl (242 kB)
Collecting Jinja2>=3.1.2 (from flask)
Using cached Jinja2-3.1.2-py3-none-any.whl (133 kB)
Collecting itsdangerous>=2.1.2 (from flask)
Using cached itsdangerous-2.1.2-py3-none-any.whl (15 kB)
Collecting click>=8.1.3 (from flask)
Using cached click-8.1.3-py3-none-any.whl (96 kB)
Collecting blinker>=1.6.2 (from flask)
Using cached blinker-1.6.2-py3-none-any.whl (13 kB)
Collecting colorama (from click>=8.1.3->flask)
Using cached colorama-0.4.6-py2.py3-none-any.whl (25 kB)
Collecting MarkupSafe>=2.0 (from Jinja2>=3.1.2->flask)
Downloading MarkupSafe-2.1.3-cp311-cp311-win_amd64.whl (17 kB)
Installing collected packages: MarkupSafe, itsdangerous, colorama, blinker, Werkzeug, Jinja2, click, flask
Successfully installed Jinja2-3.1.2 MarkupSafe-2.1.3 Werkzeug-2.3.6 blinker-1.6.2 click-8.1.3 colorama-0.4.6 flask-2.3.2 itsdangerous-2.1.2
(homepage2) C:\pytheon_myproject\homepage2\Scripts>cd..
(homepage2) C:\pytheon_myproject\homepage2>flask --app start run
Traceback (most recent call last):
File "<frozen runpy>", line 198, in _run_module_as_main
File "<frozen runpy>", line 88, in _run_code
File "C:\pytheon_myproject\homepage2\Scripts\flask.exe\__main__.py", line 7, in <module>
File "C:\pytheon_myproject\homepage2\Lib\site-packages\flask\cli.py", line 1063, in main
cli.main()
File "C:\pytheon_myproject\homepage2\Lib\site-packages\click\core.py", line 1055, in main
rv = self.invoke(ctx)
^^^^^^^^^^^^^^^^
File "C:\pytheon_myproject\homepage2\Lib\site-packages\click\core.py", line 1657, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\pytheon_myproject\homepage2\Lib\site-packages\click\core.py", line 1404, in invoke
return ctx.invoke(self.callback, **ctx.params)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\pytheon_myproject\homepage2\Lib\site-packages\click\core.py", line 760, in invoke
return __callback(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\pytheon_myproject\homepage2\Lib\site-packages\click\decorators.py", line 84, in new_func
return ctx.invoke(f, obj, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\pytheon_myproject\homepage2\Lib\site-packages\click\core.py", line 760, in invoke
return __callback(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\pytheon_myproject\homepage2\Lib\site-packages\flask\cli.py", line 911, in run_command
raise e from None
File "C:\pytheon_myproject\homepage2\Lib\site-packages\flask\cli.py", line 897, in run_command
app = info.load_app()
^^^^^^^^^^^^^^^
File "C:\pytheon_myproject\homepage2\Lib\site-packages\flask\cli.py", line 308, in load_app
app = locate_app(import_name, name)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\pytheon_myproject\homepage2\Lib\site-packages\flask\cli.py", line 218, in locate_app
__import__(module_name)
File "C:\pytheon_myproject\homepage2\start.py", line 1
Python 3.11.4 (tags/v3.11.4:d2340ef, Jun 7 2023, 05:45:37) [MSC v.1934 64 bit (AMD64)] on win32
^
SyntaxError: leading zeros in decimal integer literals are not permitted; use an 0o prefix for octal integers
start.py 의 내용은 아래와 같습니다.
# save this as app.py from flask import Flask, request from markupsafe import escape app = Flask(__name__) @app.route('/') def hello(): name = request.args.get("name", "World") return f'Hello, {escape(name)}!'
----------------------------------------------------------------