inflearn logo
강의

강의

N
챌린지

챌린지

멘토링

멘토링

N
클립

클립

로드맵

로드맵

지식공유

묻고 답해요

173만명의 커뮤니티!! 함께 토론해봐요.

코드 질문

해결됨

실전! FastAPI 입문

안녕하세요. 파이썬 2.7만 주로 쓰다 오랜만에 쓰니 좀 헷갈리는게 있어 질문드립니다. encoding: str = "UTF-8" service 작성하시면서 설명해주신 코드인데, encoding = "UTF - 8" 이렇게 써도 encoding 변수에 뭐가 들어가는지 바로 확인이 되는데 굳이 : str 과 타입을 명시할 이유가 있나요 ? 이렇게 작성하였을 때 왜 이렇게 작성하고 어떠한 장점이 있는지 궁금합니다. 비슷한 질문으로 def save_user(self, user: User) -> User: 다음과 같이 반환 타입을 적어줘야 하는 것도 설명 부탁드립니다. 작성하면서도 이걸 굳이 적어줘야 하는지가 궁금해서 질문드립니다.

  • python
  • 리팩토링
  • orm
  • FastAPI
  • pytest
인프린 댓글 1 좋아요 0 조회수 272

router testcode 문의

해결됨

실전! FastAPI 입문

router test code 에서 test_ main.py 파일에 api.todo라고 main을 바꾸어 줬는데 import를 따로 안 시켜줘도 되나요 ? main.py 는 from api import todo로 import 시키는데 test_ main.py 는 안 그래도 되는지 궁금합니다.

  • python
  • 리팩토링
  • orm
  • FastAPI
  • pytest
인프린 댓글 1 좋아요 0 조회수 315

DAY11 영상에 오타있네요

미해결

기초 알고리즘 코딩테스트 40일 완성 (by 하루코딩)

최댓값 문제 2566번인데 2556번(별 찍기 - 14)로 숫자가 잘못되어있습니다. 수정 부탁드립니다.

  • python
  • java
  • 코딩-테스트
kairs294702 댓글 2 좋아요 0 조회수 292

useQuery랑 queryClient.getQueryData랑 차이점이 있을까요??

해결됨

Next + React Query로 SNS 서비스 만들기

기본적으로 캐싱된 데이터가 있으면, 그 데이터를 가지고 오는 것으로 알고 있는데, const { data} = useQuery({ queryKey: ['posts', 'recommends'], queryFn: getPostRecommends}); const data = queryClient.getQueryData(['posts', 'recommends']); 두 가지 차이점이 있는지 궁금합니다.

  • react
  • next.js
  • react-query
  • next-auth
  • msw
oct.wanga 댓글 2 좋아요 -1 조회수 1871

docker 설치 에러

해결됨

실전! FastAPI 입문

안녕하세요. 윈도우 os 사용중이고 docker desktop 설치 시 이후 데몬이 활성화가 안되어 질문드립니다. 데몬 활성화를 위해서는 가상화 지원이 되어야 하는데, bios 세팅 및 os 가상화 설정을 모두 하여서 작업관리자에서 가상화:사용 이라고 까지 표기가 되어도 하이퍼바이저 지원이 안된다는 에러가 나옵니다. wsl 설치 또한 가상화가 지원이 안된다는 에러와 함께 설치가 안되어 구글링 이후 문의 드립니다.

  • python
  • 리팩토링
  • orm
  • FastAPI
  • pytest
인프린 댓글 1 좋아요 0 조회수 339

uvicorn 실행 에러

해결됨

실전! FastAPI 입문

안녕하세요. 학습 도중 재부팅하여 다시 uvicorn 실행하려고 하니 ERROR: Error loading ASGI app. Could not import module "main". 다음과 같은 메세지가 나오면서 fast api 앱이 실행이 안되는데 이유가 궁금합니다.

  • python
  • 리팩토링
  • orm
  • FastAPI
  • pytest
인프린 댓글 1 좋아요 0 조회수 1562

react-intersection-observer 무한스크롤페이지 중복호출문제

미해결

Next + React Query로 SNS 서비스 만들기

안녕하세요 제로초님 강의 잘 보고 있습니다. 다름아니라 무한스크롤 부분 구현중(개인 프로젝트에 해당 부분만 먼저 적용중이라 jsonplaceholder API로 호출하고 있습니다) fetchNextPage가 2번씩호출이 되어서 delay도 조정해보았는데 계속 2번씩호출이 되서 로직에 혹시 문제가 있는지 봐주실수 있을지부탁드립니다. 0. 콘솔에 확인한 결과 처음 화면에 ref가 렌더되고 그 이후 data fetching이 완료되어 isFetcing이 false가 되었는데, data를 map으로 div로 뿌리는 렌더링 과정에 시간이 소모되어 inView는 true && isFetching도 false가 되어서 div가 화면에 나타나고 ref div를 가리기 전에 data fetching을 한번씩 더 하고 있는 상황입니다. 감사합니다

  • react
  • next.js
  • react-query
  • next-auth
  • msw
나무아르볼 댓글 3 좋아요 0 조회수 1369

accounts/url 질의

미해결

장고 설계철학으로 시작하는 파이썬 장고 입문

화면과같이 include 부분 강좌와 다르게 저절로 세팅이 되고 서버 실행하면 계속 오류가나는데 어떻게해야하나요ㅜㅜ

  • python
  • django
동휘김 댓글 2 좋아요 0 조회수 260

src 디렉토리를 기본으로 설정하는 방

해결됨

실전! FastAPI 입문

from main import app이 아닌 from src.main import app을 하게 되면 에러가 발생합니다. src. 을 생략할 수 있도록 하는 방법이 없을까요

  • python
  • 리팩토링
  • orm
  • FastAPI
  • pytest
fade 댓글 2 좋아요 0 조회수 396

session.scalar(select(1)) 에러 발생 질문입니다.

해결됨

실전! FastAPI 입문

에러명은 다음과 같습니다. 도커 설정은 이상이 없는데 어디서 문제가 생긴걸까요 pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on '127.0.0.1' ([WinError 10061] 대상 컴퓨터에서 연결을 거부했으므로 연결하지 못했습니다)") The above exception was the direct cause of the following exception:

  • python
  • 리팩토링
  • orm
  • FastAPI
  • pytest
fade 댓글 1 좋아요 0 조회수 304

DATABASE_URL 상수변수 질문

해결됨

실전! FastAPI 입문

도커를 이용해 컨테이너를 실행시킬 때 root 사용자에 대해서 todos라는 비밀번호를 갖도록 설정을 해주었는데, DATABASE_URL = "mysql+pymysql://root:todos@127.0.0.1:3306/todos" 상수 변수를 이용해 데이터베이스 연결 시도 시, (1045, "Access denied for user 'root'@ 'localhos t' (using password: YES)") 이런 에러가 발생합니다. 비밀번호를 설정하였는데도 왜 이렇게 발생하는 건가요?

  • python
  • 리팩토링
  • orm
  • FastAPI
  • pytest
qpal1zm23 댓글 1 좋아요 0 조회수 266

로그인 버튼 클릭시 500에러 발생

미해결

Next + React Query로 SNS 서비스 만들기

아이디, 비밀번호를 입력하고 로그인 버튼을 누르면 500에러가 발생합니다. 9090 서버 포트는 잘 켜져있다고 뜨고, 코드 올리겠습니다. <auth.ts> import NextAuth from "next-auth"; import CredentialsProvider from "next-auth/providers/credentials"; import KakaoProvider from "next-auth/providers/kakao"; export const { handlers: { GET, POST }, auth, signIn, } = NextAuth({ pages: { signIn: "/i/flow/login", newUser: "i/flow/signup", }, providers: [ CredentialsProvider({ async authorize(credentials) { // credentials 안에 id창에서 입력하는 정보다 담겨있음 const authResponse = await fetch(`${process.env.AUTH_URL}/api/login`, { method: "POST", headers: { "Content-Type": "application/json", }, body: JSON.stringify({ id: credentials.username, password: credentials.password, //next-auth의 credentials에는 username, password로 고정되어 있어서 이를 바꿔줌 }), }); //로그인 실패시 if (!authResponse.ok) { return null; } const user = await authResponse.json(); return user; }, }), //kakao로그인을 사용할때 // KakaoProvider(), ], }); <LoginModal.tsx> "use client"; import style from "@/app/(beforeLogin)/_component/login.module.css"; import { signIn } from "next-auth/react"; import { useRouter } from "next/navigation"; import { ChangeEventHandler, FormEventHandler, useState } from "react"; export default function LoginModal() { const [id, setId] = useState(""); const [password, setPassword] = useState(""); const [message, setMessage] = useState(""); const router = useRouter(); const onSubmit: FormEventHandler<HTMLFormElement> = async (e) => { e.preventDefault(); setMessage(""); try { await signIn("credentials", { username: id, password, redirect: false, }); //kakao, naver로 바꿀 수 있음 //client 일때는 next-auth/react의 signIn을 사용 //server 일때는 @/auth의 signIn을 사용 router.replace("/home"); } catch (error) { console.log(error); setMessage("아이디와 비밀번호가 일치하지 않습니다."); } }; const onClickClose = () => { router.back(); }; const onChangeId: ChangeEventHandler<HTMLInputElement> = (e) => { setId(e.target.value); }; const onChangePassword: ChangeEventHandler<HTMLInputElement> = (e) => { setPassword(e.target.value); }; return ( <div className={style.modalBackground}> <div className={style.modal}> <div className={style.modalHeader}> <button className={style.closeButton} onClick={onClickClose}> <svg width={24} viewBox="0 0 24 24" aria-hidden="true" className="r-18jsvk2 r-4qtqp9 r-yyyyoo r-z80fyv r-dnmrzs r-bnwqim r-1plcrui r-lrvibr r-19wmn03" > <g> <path d="M10.59 12L4.54 5.96l1.42-1.42L12 10.59l6.04-6.05 1.42 1.42L13.41 12l6.05 6.04-1.42 1.42L12 13.41l-6.04 6.05-1.42-1.42L10.59 12z"></path> </g> </svg> </button> <div>로그인하세요.</div> </div> <form onSubmit={onSubmit}> <div className={style.modalBody}> <div className={style.inputDiv}> <label className={style.inputLabel} htmlFor="id"> 아이디 </label> <input id="id" className={style.input} value={id} onChange={onChangeId} type="text" placeholder="" /> </div> <div className={style.inputDiv}> <label className={style.inputLabel} htmlFor="password"> 비밀번호 </label> <input id="password" className={style.input} value={password} onChange={onChangePassword} type="password" placeholder="" /> </div> </div> <div className={style.message}>{message}</div> <div className={style.modalFooter}> <button className={style.actionButton} disabled={!id && !password}> 로그인하기 </button> </div> </form> </div> </div> ); } <middleware.ts> export { auth as middleware } from "./auth"; export const config = { matcher: ["/compose/tweet", "/home", "/explore", "/messages", "/search"], }; <route.ts> export { GET, POST } from "@/auth"; 에러 내용 : TypeError: next_dist_server_web_exports_next_request__WEBPACK_IMPORTED_MODULE_0__ is not a constructor at reqWithEnvURL (webpack-internal:///(rsc)/./node_modules/next-auth/lib/env.js:15:12) at httpHandler (webpack-internal:///(rsc)/./node_modules/next-auth/index.js:139:139) at /Users/imhwarang/projects/zerocho/z-com/node_modules/next/dist/compiled/next-server/app-route.runtime.dev.js:6:63815 at /Users/imhwarang/projects/zerocho/z-com/node_modules/next/dist/server/lib/trace/tracer.js:133:36 at NoopContextManager.with (/Users/imhwarang/projects/zerocho/z-com/node_modules/next/dist/compiled/@opentelemetry/api/index.js:1:7062) 너무 길어서 다 올릴수는 없네요 에러내용을

  • react
  • next.js
  • react-query
  • next-auth
  • msw
화랑 댓글 3 좋아요 0 조회수 1236

afterlogin beforelogin 로그인 분기처리 질문

미해결

Next + React Query로 SNS 서비스 만들기

안녕하세요. 디렉토리 구조를 afterlogin과 beforelogin구조로 나누어서 로그인을 분기치고 있고 auth.ts에서 서버로 부터 전달받은 토근값을 넣고 미들웨어에서 세션을 유무를 확인하여 login페이지로 리다이렉트 시키고 있습니다. afterlogin과 beforelogin으로 디렉토리가 어떤방식으로 나뉘는지 로직이 궁금합니다. 관련된 훅이 있는것인지?? 2. 실제 상용화된 서비스라고하면 로그인이 풀리는것을 방지하기 위해 BE로 토근값을 요청할텐데, 관련 로직은 어떤방식으로 구현하는게 좋은방법인지 요청드립니다.

  • react
  • next.js
  • react-query
  • next-auth
  • msw
댓글 1 좋아요 0 조회수 424

button과 checkbox 조건문과 함수

해결됨

5분빨리 퇴근하자! 파이썬 데이터 분석, 시각화, 웹 대시보드 제작하기

버튼과 체크박스 모두 조건문을 사용할 때는 바로 아래에 텍스트가 출력되는데, 함수를 사용하면 대시보드 맨 위에 텍스트가 호출되는 것은 왜 그런건가요?(맨 위에 텍스트가 호출되어 출력된 부분이 전부 다 한 칸 씩 밀리게 됨)

  • python
  • pandas
  • seaborn
  • plotly
  • matplotlib
  • data-visualization
  • streamlit
TEW_교육관리자 댓글 1 좋아요 0 조회수 329

MacOs, PostgreSQL16 설치, pgAdmin 4에서 connection 오류

미해결

Next + React Query로 SNS 서비스 만들기

비번 확실히 틀리지 않았는데 계속 오류 뜨길래, 완전 삭제후 다시 설치해서 비번 쉬운걸로 다시 설정하고 입력해도 계속 비번오류 뜹니다.

  • react
  • next.js
  • react-query
  • next-auth
  • msw
라푼젤 댓글 4 좋아요 2 조회수 1069

파이썬에서의 재귀

해결됨

코딩테스트 [ ALL IN ONE ]

글에 두서가 없어도 양해 바랍니다 이 수업 수강 이전에 코딩 문제를 풀 때 파이썬으로 재귀함수를 사용했던 적이 있습니다. 그때 알게 된것이 파이썬의 재귀함수에는 기본적으로 깊이의 제한이 있다는 것입니다. sys.recursionlimit()으로 확인해보니 재귀호출을 1000이상 못하도록 값이 제한되어 있고 이 값을 늘려서 사용하는것은 별로 추천되는 방법이 아닌걸로 알고 있습니다. C언어 사용할때에는 속도면에서 제한도 없고 파이썬보다 속도도 월등하다보니 재귀를 자주 사용했었는데 파이썬에서 재귀함수로 풀어야 하는 경우가 있을까요?

  • python
  • 코딩-테스트
  • 알고리즘
댓글 2 좋아요 1 조회수 361

chilrdren, modal의 보여지는 원리가 제가 이해한 것이 맞을까요?

미해결

Next + React Query로 SNS 서비스 만들기

안녕하세요 제로초님. 인터넷창에 직접 주소를 입력하거나 새로고침 시 뒤에 배경화면이 사라지는 것에 대하여 질문있습니다. 먼저 <Link href='/i/flow/signup' className={styles.signup}> 를 클릭 시에는 인터셉터 라우팅이 트리거 되어 src/app/(beforeLogin)/layout.tsx 에 있는 children으로 인해 배경화면에 main컴포넌트가 보여지며 인터셉터된 @modal 은 modal부분에 보여집니다. 그런데 직접 주소창에 /i/flow/signup' 를 입력하여 접근하거나 새로고침하면 배경화면에 main컴포넌트가 사라지게 되는데 이것의 이유는 직접 접근할 때 인터셉에 걸리지 않게되고, childrend에는 i/flow에 있는 폴더들이 보여지며 defalut.tsx가 배경화면으로 보여지기 때문인가요?

  • react
  • next.js
  • react-query
  • next-auth
  • msw
김건희 댓글 1 좋아요 0 조회수 494

annot 수치 표현

해결됨

5분빨리 퇴근하자! 파이썬 데이터 분석, 시각화, 웹 대시보드 제작하기

age_bin_list = np.arange(10, 80, 10) df['age_bin'] = pd.cut(df['age'], bins = age_bin_list) pivot_df = df.pivot_table( index = 'age_bin', columns = 'region', values = 'charges', aggfunc = 'median' # 각 구간에 해당하는 값을 중간값을 사용하겠다. ) pivot_df # 각각의 값들에 대해 크기를 가늠할 수 있게끔 시각화(주로 색상)하는 방법 # 2D 형식으로 준비된 데이터를 Seaborn heatmap으로 시각화 # annot 인자를 통해 각 셀의 값 표현 가능 fig, ax = plt.subplots() sns.heatmap(pivot_df, ax = ax, annot = True) 코드 똑같이 따라했는데 왜 저는 표에 수치가 다 표현이 안되는 건가요?

  • python
  • pandas
  • seaborn
  • plotly
  • matplotlib
  • data-visualization
  • streamlit
TEW_교육관리자 댓글 1 좋아요 0 조회수 363

CBV, FormView(폼 뷰)에 대해 알아보기 질문

해결됨

실리콘밸리 엔지니어가 가르치는 파이썬 장고 웹프로그래밍

안녕하세요 강사님 ㅎㅎ 현재 챕터도 이전과 같은 증상인데 어떻게 확인하면 좋을까요? Github snapshot: https://github.com/dimz119/learn-python-django/tree/form_view 에서 다운받아서 실행시켜도 제가 작성한 코드랑 똑같은 문제가 발생하는데 확인할수있는 방법이있을까요??

  • python
  • django
  • bootstrap
  • rest-api
  • drf
chicmania 댓글 1 좋아요 1 조회수 332

파이썬 이미지 크롤링이 안돼요..

미해결

url = " https://image.dcinside.com/viewimage.php?id=&no=24b0d769e1d32ca73de985fa11d02831f8aadc88aabcff47e8021605d37bf1436ebb78a575eb9e18042afbf9848bfd403905acb77b9ac250540b76e4781bf2 " # 헤더 추가 headers = { 'User-Agent' : 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36' , } # 이미지 다운로드 response = requests . get ( url , headers = headers ) print ( response . content ) img_data = BytesIO ( response . content ) # BytesIO 객체에서 이미지 열기 img = Image . open ( img_data ) # 이미지 저장 (optional) img . save ( "downloaded_image.jpg" ) response.content를 출력하면 b'' 이 값을 출력하게 되는데 원인을 잘 모르겠습니다.

  • python
  • 파이썬
  • 크롤링
  • crawling\
댓글 1 좋아요 1 조회수 675

인기 태그

인프런 TOP Writers

주간 인기글