Recently in the computer bawed research Tools and Applications This course, ASSIGNMENT3 teachers asked themselves to find an open source project to delve into and modify. It's interesting and useful to see developing the web with flask, and it's decided to start from there.
First build a virtual environment, using virtualenv can, I am using the Mac computer, terminal input command line sudo easy_install virtualenv can be installed. Create a microblog directory, CD-to-microblog directory input command line python-m venv flask Create a virtual environment. To install and extend the following command line:
$ flask/bin/pip Install flask$ flask/bin/pip install flask-login$ flask/bin/pip install flask-openid$ flask/bin/pip Insta ll flask-mail$ flask/bin/pip Install flask-sqlalchemy$ flask/bin/pip install sqlalchemy-migrate$ flask/bin/pip Install flask-whooshalchemy$ flask/bin/pip Install flask-wtf$ flask/bin/pip install flask-babel$ flask/bin/pip Install Guess_ language$ flask/bin/pip Install flipflop$ flask/bin/pip Install coverage
The following commands are used to create the app directory, where static files such as Js,css3,image are stored. Templates is used to store template files.
mkdir appmkdir app/staticmkdir app/templatesmkdir tmp
(MkDir's command is to create a directory)
Create a simple initialization script in the app package (file app/__init__.py ):
FlaskFlask(__name__)views
This initialization script is used to create the Application object and import the view mode.
Write the first view function (file app/views.py ):
From app import App@app.route ('/') @app. Route ('/index ') def index (): Return "Hello, world!"
Proceed to CD to microblog root directory, create run.py, launch our application development Web server.
Appapp. Run(True)
Enter the Python run.py on the command line to start the server.
Open Safari input http://localhost:5000 and Find the Hello world! instructions have been successfully started.
One of Flask's learning logs--hello world