Open jihyunjeongme opened 5 years ago
timeline 엔드포인트
Follow 기능
Unfollow 기능
Sign up
암호화 한 이후 Sign-up
아래와 같이 Hashed_password 값을 가짐
토큰 값 가져오기(Login)
토큰 값 가지고 Tweet 날리기
잘 생성된 Tweet
정상적으로 작동되는거 확인
pytest 테스트 결과(tweet 테스트)
pytest 모듈을 통해 모든 기능 테스트 결과
Amazon RDS 설정
EC2 새키 페어 생성
ssh -i /Users/jihyun/Documents/Non-business/9.\ AWS/python-restapi-backend/python-test.pem ubuntu@ec2-13-124-72-213.ap-northeast-2.compute.amazonaws.com
아래로 시도시 에러날 경우
chmod 400 파일명.pem
다시 위 커맨드 시도하면 잘됨
SHA256:12v6JYUYJAYLDAYWPs3XA/tJ47bN0ETiKPBN6DrMwbo jihyunjeongme@gmail.com
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQCyo4mrzAlQFfJuOx8rhTXEq1ZQ37e10PpcsAPSY4VsIVd8SA2wR+IFLmHJdSqHB6H5OTsCH1pjSxG4NMSVnqWkWhAxjcYG7CD+QfPhZa2SjmuWFusTFjBQ4n7DnPf9AgBrzygaMZuDSblIai8BNVxx6mlsqxZCON6Uta2KApwOkJPZtmLGpXC6QJNnuZKSXb8BtGG/gqrwBeQnB9CBgbyw6b5qf1+6q6w5wqnB7uwHcFeNr93JUX2VoO+q4abqwY66+N0UNQBQO44ueTZJHPmKqQge0Va6uvuXTcDNXyd+p8mnlGxEY+0Qc5OdxhVSrU20Y0nWOfP6sBvIfcTnZB0uMOfdx4xjFYtL/uCWGxZDIc84n5OyoyYJg+ioI/cyR3mdE68Boipis/gVMfczWROR/g45LDSY5/lPHk+ybn7VdFzmgqbr/xJ/ebxR98eM1/FpTQeGkyZtOW4uvt+3N/2N3EbbaeAgdsjI0jlAdRaDrZGTirSIbV1nY6vAPP+dbZYytcgWLft6SgT4TGQKGcm3lenHsqS0+a7pm1G+NKXTIT8SqkxQAJG+RRrSJWd6eibRneCOFgQJOBJmZJd1kmgX1uu7RRvO9+RCqBl83sGMsbxjzL0HXA9eRX0oBgGYQSAOEIc1/zRrRHuXzn6kE2qpw9x4lICdmZqbL27yJluEQQ== jihyunjeongme@gmail.com
AWS EC2에 미니콘다 다운로드
wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh
설치 및 Conda Parh에 추가
해당 사이트 참고
: https://openmmtools.readthedocs.io/en/latest/installation.html
$ wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh $ bash ./Miniconda3-latest-Linux-x86_64.sh -b -p $HOME/ubuntu/miniconda3 $ export PATH="$HOME/ubuntu/miniconda3/bin:$PATH"
파이썬 가상환결 설정 conda create --name api python=3.7
가상환경 실행 시킨 후 외부프레임 워크와 라이브러리들 설치
from mysql import connector ModuleNotFoundError: No module named 'mysql' 에러 나는 경우
$ pip search mysql-connector | grep --color mysql-connector-python
mysql-connector-python-rf (2.2.2) - MySQL driver written in Python
mysql-connector-python (2.0.4) - MySQL driver written in Python
Install the mysql-connector-python-rf -
$ pip install mysql-connector-python-rf
Verify
$ python
Python 2.7.11 (default, Apr 26 2016, 13:18:56)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-54)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import mysql.connector
>>>
아래와 같은 에러를 만날경우
sudo apt-get update sudo apt install gcc
성공적으 됨
Mysql 접근 방법
mysql -h python-backend-test.cyk5jvszavwv.ap-northeast-2.rds.amazonaws.com -u root -p
자주쓰는 명령어 minoconda 활성: export PATH="$HOME/ubuntu/miniconda3/bin:$PATH" 서버 실행: nohup python setup.py runserver --host=0.0.0.0 & 실행되는 서버 확인: ps -ef | grep runserver 서버 죽이기: kill codenumber 로그확인: vi nohup.out 확인: curl localhost:5000/ping
성공!! http -v POST "http://13.125.249.212:5000/sign-up" \ name="슈퍼맨" \ email="super@gmail.com" \ password="password_sample" \ profile="Super Developer"
ssh -i /Users/jihyun/Documents/Non-business/9.\ AWS/python-restapi-backend/python-test.pem ubuntu@ec2-13-209-35-14.ap-northeast-2.compute.amazonaws.com
SHA256:12v6JYUYJAYLDAYWPs3XA/tJ47bN0ETiKPBN6DrMwbo jihyunjeongme@gmail.com
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQCyo4mrzAlQFfJuOx8rhTXEq1ZQ37e10PpcsAPSY4VsIVd8SA2wR+IFLmHJdSqHB6H5OTsCH1pjSxG4NMSVnqWkWhAxjcYG7CD+QfPhZa2SjmuWFusTFjBQ4n7DnPf9AgBrzygaMZuDSblIai8BNVxx6mlsqxZCON6Uta2KApwOkJPZtmLGpXC6QJNnuZKSXb8BtGG/gqrwBeQnB9CBgbyw6b5qf1+6q6w5wqnB7uwHcFeNr93JUX2VoO+q4abqwY66+N0UNQBQO44ueTZJHPmKqQge0Va6uvuXTcDNXyd+p8mnlGxEY+0Qc5OdxhVSrU20Y0nWOfP6sBvIfcTnZB0uMOfdx4xjFYtL/uCWGxZDIc84n5OyoyYJg+ioI/cyR3mdE68Boipis/gVMfczWROR/g45LDSY5/lPHk+ybn7VdFzmgqbr/xJ/ebxR98eM1/FpTQeGkyZtOW4uvt+3N/2N3EbbaeAgdsjI0jlAdRaDrZGTirSIbV1nY6vAPP+dbZYytcgWLft6SgT4TGQKGcm3lenHsqS0+a7pm1G+NKXTIT8SqkxQAJG+RRrSJWd6eibRneCOFgQJOBJmZJd1kmgX1uu7RRvO9+RCqBl83sGMsbxjzL0HXA9eRX0oBgGYQSAOEIc1/zRrRHuXzn6kE2qpw9x4lICdmZqbL27yJluEQQ== jihyunjeongme@gmail.com
git clone https://github.com/jihyunjeongme/python-miniter-aws.git
Cloning into 'python-miniter-aws'...
Username for 'https://github.com': jihyunjeongme
Password for 'https://jihyunjeongme@github.com':
remote: Enumerating objects: 15, done.
remote: Counting objects: 100% (15/15), done.
remote: Compressing objects: 100% (11/11), done.
remote: Total 15 (delta 5), reused 10 (delta 3), pack-reused 0
Unpacking objects: 100% (15/15), done.
AWS EC2에 미니콘다 다운로드
wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh
설치 및 Conda Parh에 추가
해당 사이트 참고
: https://openmmtools.readthedocs.io/en/latest/installation.html
$ wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh $ bash ./Miniconda3-latest-Linux-x86_64.sh -b -p $HOME/ubuntu/miniconda3 $ export PATH="$HOME/ubuntu/miniconda3/bin:$PATH"
conda create --name api python=3.7
서버 실행: nohup python setup.py runserver --host=0.0.0.0 &
후 로그확인: vi nohup.out
할때 해당 모듈이 없다고 하면 pip install 로 설치 해줌
할때
실행되는 서버 확인: ps -ef | grep runserver 서버 죽이기: kill codenumber
pip install flask_script
추가로 아래 모듈이 없다고 하면 pip로 또 설치해줌
File "/home/ubuntu/python-miniter-aws/app.py", line 1, in <module>
import bcrypt
ModuleNotFoundError: No module named 'bcrypt'
File "setup.py", line 4, in <module>
from app import create_app
File "/home/ubuntu/python-miniter-aws/app.py", line 2, in <module>
import jwt
ModuleNotFoundError: No module named 'jwt'
File "setup.py", line 4, in <module>
from app import create_app
File "/home/ubuntu/python-miniter-aws/app.py", line 6, in <module>
from sqlalchemy import create_engine, text
ModuleNotFoundError: No module named 'sqlalchemy'
File "setup.py", line 4, in <module>
from app import create_app
File "/home/ubuntu/python-miniter-aws/app.py", line 9, in <module>
from flask_cors import CORS
ModuleNotFoundError: No module named 'flask_cors'
Traceback (most recent call last):
File "setup.py", line 5, in <module>
from flask_twisted import Twisted
ModuleNotFoundError: No module named 'flask_twisted'
`flask_twisted' 설치 아래의 에러가 발생 할 수 있음.
Command "/home/ubuntu/ubuntu/miniconda3/envs/api/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-a0pvwfyx/Twisted/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-record-ijf5f9bz/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-install-a0pvwfyx/Twisted/
그때 아래 커맨드 입력 sudo apt-get update sudo apt install gcc
그리고 다시 pip install flask-twisted
하면 정상적으로 설치됨
dbapi = dialect_cls.dbapi(**dbapi_args)
File "/home/ubuntu/ubuntu/miniconda3/envs/api/lib/python3.7/site-packages/sqlalchemy/dialects/mysql/mysqlconnector.py", line 129, in dbapi
from mysql import connector
ModuleNotFoundError: No module named 'mysql'
mysql시 아래 커맨드 입력
$ pip search mysql-connector | grep --color mysql-connector-python mysql-connector-python-rf (2.2.2) - MySQL driver written in Python mysql-connector-python (2.0.4) - MySQL driver written in Python
Install the mysql-connector-python-rf -
$ pip install mysql-connector-python-rf Verify
$ python Python 2.7.11 (default, Apr 26 2016, 13:18:56) [GCC 4.1.2 20080704 (Red Hat 4.1.2-54)] on linux2 Type "help", "copyright", "credits" or "license" for more information.
import mysql.connector
서버 실행: nohup python setup.py runserver --host=0.0.0.0 &
후 로그확인: vi nohup.out
할때
2019-04-14 05:22:35+0000 [-] Log opened.
2019-04-14 05:22:35+0000 [-] Site starting on 5000
2019-04-14 05:22:35+0000 [-] Starting factory <twisted.web.server.Site object at 0x7f77d91a0048>
위와 같이 나오면 정상적으로 실행되는중
아래와 같이 테스트 완료
Application Load Balancer
API 아키텍처 unit테스트 완료
python -mpytest -vv -s -p no:warnings