PYTHON
FastApi 이클립스 연결 후 출력해보기
9400
2023. 1. 5. 14:47
FastAPI 설치
cmd창에서 설치
pip3 install fastapi
# FastAPI 사용을 위한 설치
pip3 install uvicorn
# 파이썬 서버실행기인 uvicorn 설치
환경변수 설정



설치후
from fastapi import FastAPI
import uvicorn
app = FastAPI()
@app.get("/")
async def root():
return "Hello World"
if __name__ == "__main__":
uvicorn.run(app, host="localhost", port=8000)
아파치 톰캣 서버 종료 후


post.html 생성 후
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<form action="http://localhost:8000/post" method="post">
<input type="submit" value="포스트로보냄" />
</form>
</body>
</html>