from flask import Flask, request, jsonify
app = Flask(__name__)
@app.route('/')
def welcome():
return "안녕하세요 누구시죠? "
@app.route('/sj')
def welcome_sj():
return "윤재입니다 "
if __name__ == "__main__":
app.run(host = "0.0.0.0", port = 4332)
루트경로 | sj 경로 |
---|---|
![]() | ![]() |
1) EC2에 파일 만들기
2) 가상 환경을 통해서 위의 파일 실생시키기
3) inbound 규칙 편집
4) 접속하기
gunicorn {flask파일이름}:app --bind {ip주소}:{port번호}
nohup gunicorn {flask파일이름}:app --bind {ip주소}:{port번호} >& /dev/null &
1) nginx 설치
sudo apt install nginx
2) nginx 설치 확인
sudo systemctl status nginx
3) nginx 파일 수정
sudo vi /etc/nginx/sites-enabled/default
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
#try_files $uri $uri/ =404;
proxy_pass http://127.0.0.1:4332;
}
4) nginx 재시작
sudo systemctl restart nginx
sudo systemctl status nginx
5) 보안그룹 열어주기
6) 연결해보기