Here is an example of using Python Flask to implement a restful Web API. Small series feel very good, now share to everyone, also for everyone to make a reference. Let's take a look at it with a little knitting.
Environment Installation:
sudo pip install flask
Flask is a Python
Introduction of Flask
Flask is a Python-implemented WEB development micro-framework. Official website: http://flask.pocoo.org/
Second, Demo
1, Code structure
Copy Code code as follows:
.
├──blog.py
├──static
│├──css
││└──index.css
│├──images
││├──cat.jpg
││└──sheying1229.jpg
│└──js
└──templates
├──index.html
├──login.html
Here we will bring you the Python Flask framework application to call the Redis queue data method, so as to achieve asynchronous and non-blocking, so as to improve the performance of some programs in real-time processing. For more information, see
Asynchronous tasks
Open the browser, enter the address, and press enter to open the page. Therefore, an HTTP request is sent from the client to the server. the
Step One:First, download the compressed files you need on the website at https://files.pythonhosted.org/packages/5e/a0/ Ab7f29e32479d15663eab9afd1deea0a66fc18bf952a5453d77c7b5a92e6/spyder-3.3.0.tar.gzAfter download, unzip directly, no other actionStep Two:Enter cmd after installing SPYDER:WINDOWS+R, enter PIP install Spyder directly after enteringAfter the input is completed, the Spyder will be installed automatically, the screen will prompt a lot of progress bar and code, no tube, wait.The scre
The server_name in flask mainly do two things:
Assists flask to generate an absolute URL outside of an active request (request) (such as embedding a site URL in a message)
For child domain name support
Many people mistakenly think that it can do anything other than these two things.
One, the first thing: absolute URLwe know that url_for by default generates a relative URL, it has a parameter
This article mainly introduces how to solve the garbled problem when using SQLAlchemy in the Python Flask framework. it is very convenient to use SQLAlchemy and Python to operate databases. if you need it, refer
I. problems
In the past two days, I learned how to use flask + SQLAlchemy to customize a web Query page dem
Solve the garbled problem when using SQLAlchemy In the Python Flask framework.
I. Problems
In the past two days, I learned how to use flask + SQLAlchemy to customize a web query page demo. During the test, I found that the query results were garbled. Here we will record the solution.
Ii. Solution
1. Locate on the flask
Python setup.py install----Execute Ln-sv/usr/lo Cal/python27/bin/ipython/usr/bin/ipython--Execute the ipython command to check if the Ipython is installed successfully--Finish.Attention:Yum relies on older versions of Python, and if older versions of Python are overwritten or deleted, Yum will not be able to use it.Workaround: Modify the first line of the/usr/bi
0. PrefaceThis article explains how to use the front-end component Easyui under the Flask framework. In the flask framework, links to CSS files, JS scripts and pictures and other static files are different from other Web servers. In the flask framework, these static files are typically stored in the static folder with the Url_for function specifying the relative
( content=bson.binary.Binary(content.getvalue()), mime=mime, time=datetime.datetime.utcnow(), sha1=sha1, ) try: db.files.save(c) except pymongo.errors.DuplicateKeyError: pass return c['_id']
It's okay to upload files. however, according to the above logic, if an existing file is uploaded, the returned c ['_ id'] will be a non-existent data id. to solve this problem, it is best to return sha1. In addition, when accessing a file, modify it to access the file SHA-1 instead of
Notes on Flask in Python,
Here I will first talk about some of the first mistakes app = Flask (_ name _). When I first spelled them, I reported errors. Then I found two '_'
Configuration File
App. config. from_object (_ name _) query configuration items in the current file
App. config. from_envvar ('flaskr _ settings', silent = True) queries the configuration in
, Range (2, 25)) [5, 7, 11, 13, 17, 19, 23]Map (function, sequence) invokes function (item) for each element and returns the return value as a list. For example, the calculation cube:>>> def Cube (x): Return x*x*x...>>> Map (cube, range (1, 11)) [1, 8, 27, 64, 125, 216, 343, 512, 729, 1000]PyautoguiResources
Author Blog: http://my.oschina.net/u/1433482
contact Xu Rongzhong python development Automation test group 113938272 Weibo Http://wei
pyOpenSSL
After installation, you can begin to make your own certificates.
2. Generate a Privatekey
openssl genrsa -des3 -out server.key 1024
3. Generate. csr
openssl req -new -key server.key -out server.csr
4. Generate. key
cp server.key server.key.org openssl rsa -in server.key.org -out server.key
5. Generate. crt
openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt
Now, server. key server. crt is available in the cu
This article mainly introduced Python uses the flask frame to obtain the current query parameter The method, the example analysis Query_string obtains the query parameter the technique, needs the friend to be possible to refer to under
This example describes how Python uses the Flask framework to get the current quer
of the list (extend the original list with a new list)
4
List.index (obj)Find the index position of the first occurrence of a value from the list
5
List.insert (index, obj)Inserting an object into a list
6
List.pop (Obj=list[-1])Removes an element from the list (the last element by default), and returns the value of the element
7
List.remove (obj)To remove the first occurrence of a value in a list
8
L
.
% (ThreadName) s
The name of the thread. Probably not.
% (process) d
The process ID. Probably not.
% (message) s
User-Output messages
3. View ResultsAfter running again, you can see the log record in the TXT file under the path we setHere we see there is a applogger, this is the name of the log, through Logger.name can set this name, such as:App.logger.name="Applogger"For details, ple
of the thread. Probably not.
% (process) d
The process ID. Probably not.
% (message) s
User-Output messages
3. View ResultsAfter running again, you can see the log record in the TXT file under the path we setHere we see there is a applogger, this is the name of the log, through Logger.name can set this name, such as:App.logger.name="Applogger"For details, please refer to the official documentation: Https
Suitable object: Has a certain foundation to flask, has done the simple flask project. However, each page was rendered by Render_template. No front-end separation of project experience.Organized the online "non-Dream NJ" Children's shoes 9 article:Vue 2.0 Start (1) Scaffolding tools Vue-cli + Webstorm + webpack:https://www.jianshu.com/p/ab778fde3b99Vue 2.0 Start (2) components and Vue-router instances-Publi
I. Introduction of FLASK
Flask is a Python-implemented WEB development micro-framework. Official website: http://flask.pocoo.org/
Second, Demo
1. Code structure
Copy the Code code as follows:
.
├──blog.py
├──static
│├──css
││└──index.css
│├──images
││├──cat.jpg
││└──sheying1229.jpg
│└──js
└──templates
├──index.html
├──login.html
├──regist.html
└──upload.html
5
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.