今天的工作,老板终于要让我做CI了好感动。
###Clone the project and set up virtual environment
Choose a workspace to place the project
1234567$ mkdir gitlab$ cd mkdir$ gcl https://gitlab.com:cecid/microblog.git$ cd microblog
Set the virtual environment
1234567$ python3 -m venv flask$ source flask/bin/activate$ flask/bin/pip install --upgrade pip$ flask/bin/pip install flask flask-login flask-openid flask-mail flask-sqlalchemy flask-whooshalchemy flask-wtf flask-babel guess_language-spirit flipflop coverage tempita decorator gunicorn pbr six speaklater sqlalchemy-migrate flask-uploads pyenchant
Database connection
Connect mysql with python
pip install pymysql
- Modify
config.py
SQLALCHEMY_DATABASE_URI = 'mysql+pymysql:///username:password@localhost/databasename'
- run
$ python db_create.py
Add user
Add user
admin
whose password isadmin
12345$ flask/bin/python>> from microblog import db,models>> u = models.User(username='admin',email='email@email.com',password='admin')>> db.session.add(u)>> db.session.commit()
###Set the website can be visited from other hosts
- Modify
run.py
fromapp.run(debug=debug)
toapp.run(host='0.0.0.0',debug=debug)
Run the server
- Under the path
gitlab/microblog
, runpython run.py