Languages/Python

[django] 파이썬 애니웨어에 웹서버 업로드하기

MOONCO 2021. 4. 7. 22:48

1. github에 웹서버 업로드

git init

git remote add origin <브랜치> <github주소>

git push -u origin <브랜치>

# -u : 기본 업로드 저장소 지정

 

 

2. 파이썬 애니웨어 가입

 

Host, run, and code Python in the cloud: PythonAnywhere

Batteries included With Python versions 2.7, 3.5, 3.6, 3.7 and 3.8, and all the goodies you normally find in a Python installation, PythonAnywhere is also preconfigured with loads of useful libraries, like NumPy, SciPy, Mechanize, BeautifulSoup, pycrypto,

www.pythonanywhere.com

 

 

3. 파이썬 애니웨어에 git clone

git init

git clone <github주소>

 

 

4. virtualenv로 가상환경 구성

pip install virtualenv

virtualenv --python=python3.6 myvenv

# myvenv 라는 이름의 python3.6 가상환경을 구성함

 

 

5. 가상환경 접속

source myvenv/bin/activate

# myvenv 폴더가 있는 위치에서 명령어 실행

 

 

6. django 설치

(myvenv) pip install django

 

 

7. 파이썬 애니웨어에서 웹앱 프로젝트 생성

첫 화면
주소창 생성화면

 

파이썬 웹프레임워크 고르기 (django)

 

사용할 파이썬 버전 선택

 

프로젝트 이름/폴더경로 설정

 

웹 앱 생성완료

 

 

8. 가상환경 경로 설정

myvenv 생성 경로 입력하기

 

9. 코드 경로지정

"/home/<파이썬애니웨어ID>/프로젝트" 으로 코드 경로 지정

 

 

10. wsgi  설정하기 ( 위 사진에서 pythonanywhere_com_wsgi.py 클릭 )

import os
import sys


project_home = '/home/<파이썬애니웨어ID>/<프로젝트>'
if project_home not in sys.path:
    sys.path.insert(0, project_home)

# set environment variable to tell django where your settings.py is
os.environ['DJANGO_SETTINGS_MODULE'] = '<프로젝트>.settings'


# serve django via WSGI
from django.core.wsgi import get_wsgi_application
from django.contrib.staticfiles.handlers import StaticFilesHandler
application = StaticFilesHandler(get_wsgi_application())

 

 

11. 서버 재실행

재실행 중..

 

 

12. 서버 접속

반응형