One of Flask's learning logs--hello world

Source: Internet
Author: User
Tags virtualenv

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.