ππ»4. Web site publish
Contents
Ch4 Web Site Publish
Video Content
4-1: Publish process
OpenCV+WebApp - ch4 web site publish (1/4), publish structure
4-2: Local repository & GitHub
OpenCV+WebApp - ch4 web site publish (2/4), Local Repository & Github
4-3: Web site upload & server setting
OpenCV+WebApp - ch4 web site publish (3/4), server setting
4-4: Publish & boast
OpenCV+WebApp - ch4 web site publish (4/4), server setting & publish
1. Github setting
- Go to github.com and sign up (free)
- Create new repository
Step 1:


Step 2:


2. Local
Git setting
Install git
$ sudo apt install git
Make git repository
/cvlecture$ git init
Initialized empty Git repository in /home/parallels/Documents/cvlecture/.git/
/cvlecture$ git config --global user.name "Your Name"
/cvlecture$ git config --global user.email you@example.com
Make ignore file
/cvlecture$ nano .gitignore
*.pyc
*~
__pycache__
myvenv
db.sqlite3
/static
.DS_Store
β control + o : write, control+x : exit
Git commit
/cvlecture$ git status # check unupdated files
/cvlecture$ git add . # add all file
/cvlecture$ git commit -m 'first commit' # commit & message
Set remote repository & push
/cvlecture$ git remote add origin https://github.com/MareArts/cvlecture_opencv_webapp.git
/cvlecture$ git push -u origin master # upload file to repository
/cvlecture$ git config push.default current # tip for git push


3. Server (pythonanywhere)
- Go to www.pythonanywhere.com and signup (free)
- Add new app: Manual configuration β python 3.6





Download file from remote repository
Go to Consoles page
$ git clone https://github.com/MareArts/cvlecture_opencv_webapp.git


Make virtualenv
~/cvlecture $ mkvirtualenv envpy3 -p python3
Set virtualenv on web page

/home/cvlecture/.virtualenvs/envpy3
Set WSGI on web page

import os
import sys
path = '/home/cvlecture/cvlecture_opencv_webapp' # input your account !!
if path not in sys.path:
sys.path.append(path)
os.environ['DJANGO_SETTINGS_MODULE'] = 'cvlecture_site.settings' # input your webapp !!
from django.core.wsgi import get_wsgi_application
from django.contrib.staticfiles.handlers import StaticFilesHandler
application = StaticFilesHandler(get_wsgi_application())
Virtualenv update
!! at local (your computer) !!
(envpy3) $ pip freeze > requirements.txt # save installed lists
#git push
(envpy3) $ git add .
(envpy3) $ git commit -m 'add requirements.txt'
(envpy3) $ git push
!! at server (pythonanywhere) !!
(envpy3) $ git pull
(envpy3) $ pip install -r requirements.txt # install using lists




Migration
!! at server (pythonanywhere) !!
(envpy3) $ python manage.py migrate

Refresh website
Click reload button

Result

ππ» Thank you!
π Source code, Material(pdf) and example images π
https://www.marearts.com/products/opencv-django-webapp-lecture-materials