[BACKEND]파이썬_Fast API①



파이썬 설치
https://www.python.org/downloads/release/python-3100/
Python Release Python 3.10.0
The official home of the Python Programming Language
www.python.org
파이썬 3.10.0 설치
파이썬 설치 후 cmd에서 파일 생성

powershell
Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.
새로운 크로스 플랫폼 PowerShell 사용 https://aka.ms/pscore6
PS C:\aix3> ls
디렉터리: C:\aix3
---- ------------- ------ ----
d----- 2024-02-01 오전 10:00 fa_venv
d----- 2024-02-01 오전 9:59 fa_veny
d----- 2024-02-01 오전 9:51 python_ex
PS C:\aix3> rm -rf .\fa_veny
Remove-Item : 매개 변수 이름 'rf'과(와) 일치하는 매개 변수를 찾을 수 없습니다.
위치 줄:1 문자:4
+ rm -rf .\fa_veny
PS C:\aix3> rm -r .\fa_veny
PS C:\aix3> ls
디렉터리: C:\aix3
Mode LastWriteTime Length Name
---- ------------- ------ ----
d----- 2024-02-01 오전 10:00 fa_venv
d----- 2024-02-01 오전 9:51 python_ex
(fa_venv) PS C:\aix3> mkdir fastapi_ex
디렉터리: C:\aix3
Mode LastWriteTime Length Name
---- ------------- ------ ----
d----- 2024-02-01 오전 10:13 fastapi_ex
(fa_venv) PS C:\aix3> cd .\fa_venv\
(fa_venv) PS C:\aix3\fa_venv> cd ..
(fa_venv) PS C:\aix3> ls
디렉터리: C:\aix3
Mode LastWriteTime Length Name
---- ------------- ------ ----
d----- 2024-02-01 오전 10:13 fastapi_ex
d----- 2024-02-01 오전 10:00 fa_venv
d----- 2024-02-01 오전 9:51 python_ex
(fa_venv) PS C:\aix3> cd .\fastapi_ex\
(fa_venv) PS C:\aix3\fastapi_ex> ls
(fa_venv) PS C:\aix3\fastapi_ex> mkdir todos
디렉터리: C:\aix3\fastapi_ex
Mode LastWriteTime Length Name
---- ------------- ------ ----
d----- 2024-02-01 오전 10:13 todos
(fa_venv) PS C:\aix3\fastapi_ex> cd
(fa_venv) PS C:\aix3\fastapi_ex> cd .\todos\
















code. 를 치면 vscode 창이 열린다.














딕셔너리 사용하기

이미지 넣기

지금은 이미지가 안나온다.

# static 폴더(정적파일 폴더)를 app에 연결
- 자동임포트 : ctrl + .

# 절대 패스
abs_path = os.path.dirname(os.path.realpath(__file__))
앱솔루트 패쓰
abs_path = os.path.dirname(os.path.realpath(__file__))
# print(abs_path)
# html 템플릿 폴더를 지정하여 jinja템플릿 객체 생성
# templates = Jinja2Templates(directory="templates") templates = Jinja2Templates(directory=f"{abs_path}/templates"

시멘틱(=부트스트랩 유사) 적용하기
cdn 링크 html> 헤드태그 안에 복붙
https://semantic-ui.com/introduction/advanced-usage.html



Develop a Simple Python FastAPI ToDo App in 1 minute - DEV Community




semantic-ui로 UI 표현 참고 문서 :
https://dev.to/nditah/develop-a-simple-python-fastapi-todo-app-in-1-
minute-8dg semantic-ui 2.4 version
https://semantic-ui.com/introduction/advanced-usage.html
https://semantic-ui.com/elements/image.html
Recipes | Semantic UI
semantic-ui.com