Flask Simple Web Application

Source: Internet
Author: User

Recommend a learning Python Web site, personally feel that there is a big harvest here, hope to learn flask later small partners to help. http://www.pythondoc.com/

Implementation of the first Web application with the Flask framework

first you need to figure out a few concepts:

1. View: A view is a processor that responds to requests from a Web browser. In Flask, the view is written as a Python function that implements functionality inside. Each view function is a URL that maps to one or more requests.

2. Applications: Used to create application objects, import views, etc.

3. Startup script: The script used to start the Web server, that is, run.py.

The above mentioned "concept" is actually a few steps to implement a Web application, just touch Web development Some things are not particularly clear, for the record here.

I put all the "apps" in the "Apps" folder, in the Flask directory.

Create views.py views and __init__.py initializers in the app folder, respectively.

views.py

 from Import App@app.route ('/') @app. Route ('/index' ) )def  index ():    return"Hello, world! "

__init__.py

 from Import  = Flask (__name__)fromimport views

You can then start the Web server with run.py in scripts.

run.py

# !flask/bin/python  from Import  = True)

Finally run the run.py script, access to 127.0.0.1:5000 can see the implementation of the small program.

Flask Simple Web Application

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.