[Python] Create a minimal website in Python using the Flask Microframework
Python in The Using create Flask website
2023-09-14 09:00:50 时间
How to install Flask Use Flask to create a minimal website Build routes in Flask to respond to website endpoints Use Variable Rules to pass parts of the URL to your functions as keyword parameters
Install:
pip install Flask
Development Mode:
run_local.sh:
#!/bin/bash export FLASK_APP=app.py export FLASK_DEBUG=1 flask run
app.py:
from flask import Flask app = Flask(__name__) @app.route('/') def hello_world(): return 'Hello world!' @app.route('/foo/') def foo(): return 'The foo page' @app.route('/bar') def bar(): return 'The bar page' @app.route('/hello/') @app.route('/hello/<name>') def say_hello(name=None): return 'Hello {}'.format(user)
相关文章
- [Python] Understand Scope in Python
- [Python] Find available methods and help in REPL
- python print 打印的数据包含中文,打印报错UnicodeDecodeError: 'gbk' codec can't decode bytes in position 459-460: illegal multibyte sequence解决办法
- [Python] Reuse Code in Multiple Projects with Python Modules
- [Python] Manipulate Data with Dictionaries in Python
- [Python] Understand List Comprehensions in Python
- [Python] Find available methods and help in REPL
- Member functions in Python
- Loggers in Python
- Python version 2.7 required, which was not found in the registry解决方法
- Python 路径库pathlib常用函数
- Python Django 一对多之插入多条数据示例
- Python之tkinter:动态演示调用python库的tkinter带你进入GUI世界(Menu的Command)
- 已解决WARNING: pip is configured with locations that require TLS/SSL, however the ssl module in Python
- 〖Python零基础入门篇㊱〗- 装饰器与类的装饰器
- python 中文语音转为钢琴曲
- 牛客华为机试第1题python
- python的class的__str__和__repr__(转)
- Python使用4个空格替换Tab, TabError: inconsistent use of tabs and spaces in indentation。
- *args and **kwargs in Python 变长参数
- 老司机教你如何学习Python数据分析
- Import Modules in Python
- 【Python 问题解决】---- ModuleNotFoundError: No module named ‘xlwt‘