当前位置:网站首页>How to use pycharm to quickly create a flask project
How to use pycharm to quickly create a flask project
2022-07-28 20:09:00 【LucaTech】
Create a new Flask project
File - New Project
choice Flask
Then the following three files are automatically included in the created folder :
among app.py The default format of is as follows :
from flask import Flask
app = Flask(__name__)
@app.route('/')
def hello_world(): # put application's code here
return 'Hello World!'
if __name__ == '__main__':
app.run()
route
Let multiple URL Show the same content
@app.route('/')
@app.route('/home')
def home():
return 'Hello, World!'
Exhibition HTML
return Write directly behind HTML Code
from flask import Flask
app = Flask(__name__)
@app.route('/')
@app.route('/home')
def home():
return '<h1>Hello, World!</h1>'
@app.route('/reporter')
def reporter():
return ''' <h2>Reporter Bio</h2> <a href='/'>Return to home page</a> '''
Variable Variable Rules
imagine , We have a lot of order_name And corresponding order_id, What we need to show url As shown below :
- /orders/john/001
- /orders/alice/002
- /orders/bob/003
- …
You can use <> On behalf of the variable , The data type can be set before the variable name
@app.route('/orders/<user_name>/<int:order_id>')
def orders(user_name, order_id):
return f'<p>Fetching order #{
order_id} for {
user_name}.</p>'
边栏推荐
- HSETNX KEY_ Name field value usage
- 7. Functions of C language, function definitions and the order of function calls, how to declare functions, prime examples, formal parameters and arguments, and how to write a function well
- [wechat applet development] page navigation and parameter transmission
- [C language] random number generation and `include < time. H > 'learning
- 爬取IP
- MySQL command statement (personal summary)
- 1. C language variable type, global variable, local variable
- [C language] step jumping problem [recursion]
- [in depth study of 4g/5g/6g topics -44]: urllc-15 - in depth interpretation of 3GPP urllc related protocols, specifications and technical principles -9-low delay technology -3-non slot scheduling mini
- Cloud computing notes part.1 - system management
猜你喜欢

Prometheus deployment

4. Const and difine and the problem of initializing arrays with const and define

English translation Arabic - batch English translation Arabic tools free of charge

In the second half of 2022, the system integration project management engineer certification starts on August 20

The cloud native programming challenge is hot, with 510000 bonus waiting for you to challenge!

Cloud computing notes part.2 - Application Management
![[C language] header file of complex number four operations and complex number operations](/img/f9/b389fe5367f1fa6cd18aaac856bc0d.png)
[C language] header file of complex number four operations and complex number operations

党员故事|李青艾用漫画带动农民增收致富

How many types of rain do you know?

JVM (24) -- performance monitoring and tuning (5) -- Analyzing GC logs
随机推荐
Implementation of strstr in C language
中国能否在元宇宙的未来发展中取得突破,占领高地?
Const pointer of C language and parameter passing of main function
Array method added in ES6
English translation Portuguese - batch English conversion Portuguese - free translation and conversion of various languages
[C language] simulation implementation of strlen (recursive and non recursive)
Implementation of memmove in C language
Information management system and games based on C language
C language operators and input and output
Longest Palindromic Substring
Leetcode day3 employees who exceed the manager's income
Redis notes
党员故事|李青艾用漫画带动农民增收致富
[C language] shutdown game [loop and switch statement]
Getting started with enterprise distributed crawler framework
Can China make a breakthrough in the future development of the meta universe and occupy the highland?
Using Lex (Flex) to generate lexical analyzer of PL language
一文读懂如何部署具有外部数据库的高可用 K3s
Advanced notes (Part 2)
Application skills of programming rising and falling edge instructions of botu 1200/1500plc (bool array)