当前位置:   article > 正文

如何用python编写抢票软件,python爬虫小程序抢购_python微信小程序抢票

python微信小程序抢票

大家好,小编来为大家解答以下问题,python小程序抢购脚本怎么写,如何用python编写抢票软件,今天让我们一起来看看吧!

本篇文章给大家谈谈python小程序抢购脚本,以及python简单小程序代码,希望对各位有所帮助,不要忘了收藏本站喔。

安装flask

  1. 创建一个flask虚拟环境
  2. [root@shaoyu ~]# mkvirtualenv flask
  3. 进入flask虚拟环境并安装falsk
  4. (flask) [root@shaoyu ~]# pip install flask #pip源如果是国外的,可能安装过程会很漫长,更换到国内pip源即可,另外一个因素受限于个人网络环境
  5. #测试倒入flask是否成功
  6. (flask) [root@shaoyu ~]# python
  7. Python 3.6.10 (default, Jul 22 2020, 11:39:06)
  8. [GCC 4.8.5 20150623 (Red Hat 4.8.5-39)] on linux
  9. Type "help", "copyright", "credits" or "license" for more information.
  10. >>> import flask
  11. >>> exit() #导入没问题
  12. (flask) [root@shaoyu ~]#

测试flask

  1. (flask) [root@shaoyu ~]# mkdir flask
  2. (flask) [root@shaoyu ~]# vim flask/hello.py
  3. from flask import Flask
  4. app = Flask(__name__)
  5. @app.route('/')
  6. def hello_world():
  7. return "Hello World!"
  8. if __name__ == '__main__':
  9. app.run()
  10. 运行hello.py
  11. (flask) [root@shaoyu flask]# python hello.py
  12. * Serving Flask app "hello" (lazy loading)
  13. * Environment: production
  14. WARNING: This is a development server. Do not use it in a production deployment.
  15. Use a production WSGI server instead.
  16. * Debug mode: off
  17. * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
  18. 在另外一个终端中访问测试
  19. [root@shaoyu ~]# elinks 127.0.0.1:5000 --dump
  20. Hello World!
  21. 证明flask没问题

flask框架之路由规划

  1. (flask) [root@shaoyu flask]# vim 01-hello.py
  2. #-*- coding:utf-8 -*-
  3. from flask import Flask
  4. app = Flask(__name__)
  5. @app.route('/')
  6. def hello_world():
  7. return "Hello World!"
  8. @app.route("/api")
  9. def index()
  10. return "Index page"
  11. @app.route("/api/hello")
  12. def hello()
  13. return "Hello World"
  14. if __name__ == '__main__':
  15. app.run()
  16. #app.run( host='0.0.0.0' ) #监听所有端口,用于宿主机访问测试
  17. 运行01-hello.py
  18. (flask) [root@shaoyu flask]# python 01-hello.py
  19. 在另一个终端中查看结果
  20. [root@shaoyu ~]# elinks 127.0.0.1:5000 --dump
  21. Hello World!
  22. [root@shaoyu ~]# elinks 127.0.0.1:5000/api --dump
  23. Index page
  24. [root@shaoyu ~]# elinks 127.0.0.1:5000/api/hello --dump
  25. Hello World

flask.register._blueprint方法

  1. (flask) [root@shaoyu flask]# pwd
  2. /root/flask
  3. (flask) [root@shaoyu flask]# ls
  4. 01-hello.py hello.py
  5. (flask) [root@shaoyu flask]# vim imooc.py
  6. #-*- coding:utf-8 -*-
  7. from flask import Blueprint
  8. route_imooc = Blueprint( "imooc_page", __name__ )
  9. @route_imooc.route('/')
  10. def index():
  11. return "imooc index page"
  12. @route_imooc.route('/hello')
  13. def hello():
  14. return "imooc hello world"
  15. (flask) [root@shaoyu flask]# cp 01-hello.py 02-hello-imooc.py
  16. (flask) [root@shaoyu flask]# vim 02-hello-imooc.py
  17. (flask) [root@shaoyu flask]# cat 02-hello-imooc.py
  18. #-*- coding:utf-8 -*-
  19. from flask import Flask
  20. from imooc import route_imooc
  21. app = Flask(__name__)
  22. app.register_blueprint( route_imooc, url_prefix = '/imooc' )
  23. @app.route('/')
  24. def hello_world():
  25. return "Hello World!"
  26. @app.route("/api")
  27. def index():
  28. return "Index page"
  29. @app.route("/api/hello")
  30. def hello():
  31. return "Hello World"
  32. if __name__ == '__main__':
  33. app.run()
  34. #app.run( host='0.0.0.0' ) #监听所有端口,用于宿主机访问测试
  35. (flask) [root@shaoyu flask]# ls
  36. 01-hello.py 02-hello-imooc.py hello.py imooc.py

运行02-hello-imooc.py

  1. (flask) [root@shaoyu flask]# python 02-hello-imooc.py
  2. * Serving Flask app "02-hello-imooc" (lazy loading)
  3. * Environment: production
  4. WARNING: This is a development server. Do not use it in a production deployment.
  5. Use a production WSGI server instead.
  6. * Debug mode: off
  7. * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
  8. 在另外一个终端中测试
  9. [root@shaoyu ~]# elinks 127.0.0.1:5000 --dump
  10. Hello World!
  11. [root@shaoyu ~]# elinks 127.0.0.1:5000/imooc/hello --dump
  12. imooc hello world
  13. [root@shaoyu ~]# elinks 127.0.0.1:5000/imooc/ --dump
  14. imooc index page

flask之链接管理器(url_for)和版本管理器

  1. 链接管理器url_for
  2. (flask) [root@shaoyu flask]# cp 02-hello-imooc.py 03-url_for.py
  3. (flask) [root@shaoyu flask]# vim 03-url_for.py
  4. #-*- coding:utf-8 -*-
  5. from flask import Flask,url_for
  6. from imooc import route_imooc
  7. app = Flask(__name__)
  8. app.register_blueprint( route_imooc, url_prefix = '/imooc' )
  9. @app.route('/')
  10. def hello_world():
  11. url = url_for( 'index' )
  12. return "Hello World," + url
  13. @app.route("/api")
  14. def index():
  15. return "Index page"
  16. @app.route("/api/hello")
  17. def hello():
  18. return "Hello World"
  19. if __name__ == '__main__':
  20. app.run()
  21. #app.run( host='0.0.0.0' ) #监听所有端口,用于宿主机访问测试
  22. (flask) [root@shaoyu flask]# python 03-url_for.py
  23. [root@shaoyu ~]# elinks 127.0.0.1:5000 --dump
  24. Hello World,/api
  25. (flask) [root@shaoyu flask]# mkdir common
  26. (flask) [root@shaoyu flask]# touch common/__init__.py
  27. (flask) [root@shaoyu flask]# mkdir common/libs
  28. (flask) [root@shaoyu flask]# touch common/libs/UrlManager.py
  29. (flask) [root@shaoyu flask]# touch common/libs/__init__.py
  30. (flask) [root@shaoyu flask]# vim common/libs/UrlManager.py
  31. #-*- coding:utf-8 -*-
  32. class UrlManager(object):
  33. @staticmethod
  34. def buildUrl( path ):
  35. return path
  36. @staticmethod
  37. def buildStaticUrl( path ):
  38. return path
  39. (flask) [root@shaoyu flask]# vim 04-url_for.py
  40. #-*- coding:utf-8 -*-
  41. from flask import Flask,url_for
  42. from imooc import route_imooc
  43. from common.libs.UrlManager import UrlManager
  44. app = Flask(__name__)
  45. app.register_blueprint( route_imooc, url_prefix = '/imooc' )
  46. @app.route('/')
  47. def hello_world():
  48. url = url_for( 'index' )
  49. url_1 = UrlManager.buildUrl( '/api' )
  50. return "Hello World, url:%s, url_1:%s"%( url, url_1)
  51. @app.route("/api")
  52. def index():
  53. return "Index page"
  54. @app.route("/api/hello")
  55. def hello():
  56. return "Hello World"
  57. if __name__ == '__main__':
  58. app.run()
  59. #app.run( host='0.0.0.0' ) #监听所有端口,用于宿主机访问测试
  60. (flask) [root@shaoyu flask]# python 04-url_for.py
  61. [root@shaoyu ~]# elinks 127.0.0.1:5000 --dump
  62. Hello World, url:/api, url_1:/api
  63. (flask) [root@shaoyu flask]# vim 05-url_for_version.py
  64. #-*- coding:utf-8 -*-
  65. '''
  66. 每次发版都会有对应的版本号,如(202007211710,202007212210),这里为了举例,先随机定义一个版本号
  67. '''
  68. from flask import Flask,url_for
  69. from imooc import route_imooc
  70. from common.libs.UrlManager import UrlManager
  71. app = Flask(__name__)
  72. app.register_blueprint( route_imooc, url_prefix = '/imooc' )
  73. @app.route('/')
  74. def hello_world():
  75. url = url_for( 'index' )
  76. url_1 = UrlManager.buildUrl( '/api' )
  77. url_2 = UrlManager.buildStaticUrl('/css/bootstrap.css')
  78. return "Hello World, url:%s, url_1:%s, url_2:%s"%( url, url_1, url_2)
  79. @app.route("/api")
  80. def index():
  81. return "Index page"
  82. @app.route("/api/hello")
  83. def hello():
  84. return "Hello World"
  85. if __name__ == '__main__':
  86. app.run()
  87. #app.run( host='0.0.0.0' ) #监听所有端口,用于宿主机访问测试
  88. (flask) [root@shaoyu flask]# cat common/libs/UrlManager.py
  89. #-*- coding:utf-8 -*-
  90. class UrlManager(object):
  91. @staticmethod
  92. def buildUrl( path ):
  93. return path
  94. @staticmethod
  95. def buildStaticUrl( path ):
  96. path = path + '?ver=' + '202007212210' #这里先把这个版本号写死,为了验举例
  97. return UrlManager.buildUrl( path )
  98. (flask) [root@shaoyu flask]# python 05-url_for_version.py
  99. [root@shaoyu ~]# elinks 127.0.0.1:5000 --dump
  100. Hello World, url:/api, url_1:/api,
  101. url_2:/css/bootstrap.css?ver=202007212210

详细的用法后续会再做详细介绍

flask日志系统

  1. (flask) [root@shaoyu flask]# cat 06-flask_log.py
  2. #-*- coding:utf-8 -*-
  3. '''
  4. 每次发版都会有对应的版本号,如(202007211710,202007212210)
  5. '''
  6. from flask import Flask,url_for
  7. from imooc import route_imooc
  8. from common.libs.UrlManager import UrlManager
  9. app = Flask(__name__)
  10. app.register_blueprint( route_imooc, url_prefix = '/imooc' )
  11. @app.route('/')
  12. def hello_world():
  13. url = url_for( 'index' )
  14. url_1 = UrlManager.buildUrl( '/api' )
  15. url_2 = UrlManager.buildStaticUrl('/css/bootstrap.css')
  16. msg = "Hello World, url:%s, url_1:%s, url_2:%s"%( url, url_1, url_2)
  17. app.logger.error( msg )
  18. app.logger.info( msg )
  19. app.logger.debug( msg )
  20. return msg
  21. @app.route("/api")
  22. def index():
  23. return "Index page"
  24. @app.route("/api/hello")
  25. def hello():
  26. return "Hello World"
  27. if __name__ == '__main__':
  28. #app.run()
  29. app.run( host='0.0.0.0', debug = True ) #监听所有端口,用于宿主机访问测试;debug = true表示开启开发者调试模式,在运行程序时,可以直接更改文件而不需要停掉程序重新运行
  30. 运行06-flask_log.py观察输出结果,debug开启时,运行中的程序会实时扫描06-flask_log.py文件,并输出更新内容
  31. * Detected change in '/root/flask/06-flask_log.py', reloading
  32. * Restarting with stat
  33. * Debugger is active!
  34. * Debugger PIN: 125-377-728
  35. [2020-07-22 17:40:05,367] ERROR in 06-flask_log: Hello World, url:/api, url_1:/api, url_2:/css/bootstrap.css?ver=202007212210
  36. [2020-07-22 17:40:05,367] INFO in 06-flask_log: Hello World, url:/api, url_1:/api, url_2:/css/bootstrap.css?ver=202007212210
  37. [2020-07-22 17:40:05,367] DEBUG in 06-flask_log: Hello World, url:/api, url_1:/api, url_2:/css/bootstrap.css?ver=202007212210

flask错误处理

  1. (flask) [root@shaoyu flask]# cp hello.py 07-flask_error.py
  2. (flask) [root@shaoyu flask]# vim 07-flask_error.py
  3. from flask import Flask
  4. app = Flask(__name__)
  5. @app.route('/')
  6. def hello_world():
  7. return "Hello World!"
  8. @app.errorhandler(404)
  9. def page_not_found(error):
  10. app.logger.error( error )
  11. return "This is page are not exist", 404
  12. if __name__ == '__main__':
  13. app.run( host='0.0.0.0', debug = True ) #监听所有端口,用于宿主机访问测试
  14. 运行程序
  15. (flask) [root@shaoyu flask]# python 07-flask_error.py
  16. 在另一个终端中测试一个不存在的地址
  17. [root@shaoyu flask]# elinks 127.0.0.1:5000/haha/ --dump
  18. This is page are not exist
  19. 回到刚才运行程序窗口观察实时输出
  20. * Serving Flask app "07-flask_error" (lazy loading)
  21. * Environment: production
  22. WARNING: This is a development server. Do not use it in a production deployment.
  23. Use a production WSGI server instead.
  24. * Debug mode: on
  25. * Running on http://0.0.0.0:5000/ (Press CTRL+C to quit)
  26. * Restarting with stat
  27. * Debugger is active!
  28. * Debugger PIN: 125-377-728
  29. [2020-07-22 17:48:48,504] ERROR in 07-flask_error: 404 Not Found: The requested URL was not found on the server. If you entered the URL manually please check your spelling and try again.
  30. 127.0.0.1 - - [22/Jul/2020 17:48:48] "GET /haha/ HTTP/1.1" 404 -
  31. [2020-07-22 17:49:08,015] ERROR in 07-flask_error: 404 Not Found: The requested URL was not found on the server. If you entered the URL manually please check your spelling and try again.

flask框架之数据库ORM

  1. mysql数据库的配置这里就不再赘述了,在安装mysql的时候已经重置过mysql密码了python画心的代码演示。这里直接进行flask-sqlalchemy的安装
  2. (flask) [root@shaoyu flask]# pip install flask-sqlalchemy
  3. 安装mysqlclient
  4. 解决依赖
  5. (flask) [root@shaoyu flask]# yum install -y mysql-devel gcc gcc-devel python-devel
  6. (flask) [root@shaoyu flask]# pip install mysqlclient

创建08-falsk_mysql.py进行测试

  1. (flask) [root@shaoyu flask]# vim 08-flask_mysql.py
  2. #-*- coding:utf-8 -*-
  3. '''
  4. 每次发版都会有对应的版本号,如(202007211710,202007212210)
  5. '''
  6. from flask import Flask,url_for
  7. from imooc import route_imooc
  8. from common.libs.UrlManager import UrlManager
  9. from flask_sqlalchemy import SQLAlchemy
  10. app = Flask(__name__)
  11. app.register_blueprint( route_imooc, url_prefix = '/imooc' )
  12. app.config['SQLALCHEMY_DATABASE_URI'] = 'mysql://root:Mysql-123@127.0.0.1/mysql'
  13. db = SQLAlchemy(app)
  14. @app.route('/')
  15. def hello_world():
  16. url = url_for( 'index' )
  17. url_1 = UrlManager.buildUrl( '/api' )
  18. url_2 = UrlManager.buildStaticUrl('/css/bootstrap.css')
  19. msg = "Hello World, url:%s, url_1:%s, url_2:%s"%( url, url_1, url_2)
  20. app.logger.error( msg )
  21. app.logger.info( msg )
  22. app.logger.debug( msg )
  23. return msg
  24. @app.route("/api")
  25. def index():
  26. return "Index page"
  27. @app.route("/api/hello")
  28. def hello():
  29. from sqlalchemy import text
  30. sql = text('select * from `user`')
  31. result = db.engine.execute( sql )
  32. for row in result:
  33. app.logger.info( row )
  34. return "Hello World"
  35. if __name__ == '__main__':
  36. #app.run()
  37. app.run( host='0.0.0.0', debug = True ) #监听所有端口,用于宿主机访问测试;debug = true表示开启开发者调试模式,在运行程序时,可以直接更改文件而不需要停掉程序重新运行

访问测试

  1. (flask) [root@shaoyu flask]# python 08-flask_mysql.py
  2. 在另一个终端中访问
  3. (flask) [root@shaoyu flask]# elinks 127.0.0.1:5000/api/hello --dump
  4. 切回运行程序终端查看
  5. * Debugger is active!
  6. * Debugger PIN: 125-377-728
  7. [2020-07-23 08:03:07,031] INFO in 08-flask_mysql: ('localhost', 'root', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', '', b'', b'', b'', 0, 0, 0, 0, 'mysql_native_password', '*FC9B6504FDD72E185BAC4C3F5BC3AFDD51069E55', 'N', datetime.datetime(2020, 7, 22, 9, 58, 12), None, 'N')
  8. [2020-07-23 08:03:07,032] INFO in 08-flask_mysql: ('localhost', 'mysql.session', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'Y', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', '', b'', b'', b'', 0, 0, 0, 0, 'mysql_native_password', '*THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE', 'N', datetime.datetime(2020, 7, 22, 9, 49, 35), None, 'Y')
  9. [2020-07-23 08:03:07,032] INFO in 08-flask_mysql: ('localhost', 'mysql.sys', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', '', b'', b'', b'', 0, 0, 0, 0, 'mysql_native_password', '*THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE', 'N', datetime.datetime(2020, 7, 22, 9, 49, 35), None, 'Y')
  10. 127.0.0.1 - - [23/Jul/2020 08:03:07] "GET /api/hello HTTP/1.1" 200 -

构建高可用的Flask MVC框架(类似下面这种文件结构)

查看目录结构

  1. xueji/
  2. ├── application.py
  3. ├── common
  4. │   ├── __init__.py
  5. │   ├── libs
  6. │   │   └── __init__.py
  7. │   └── models
  8. │   └── __init__.py
  9. ├── config
  10. │   ├── base_setting.py
  11. │   ├── __init__.py
  12. │   ├── local_setting.py
  13. │   └── production_setting.py
  14. ├── docs
  15. │   └── mysql.md
  16. ├── jobs
  17. │   ├── __init__.py
  18. │   └── tasks
  19. │   └── __init__.py
  20. ├── manager.py
  21. ├── __pycache__
  22. │   ├── application.cpython-36.pyc
  23. │   └── www.cpython-36.pyc
  24. ├── readme.md
  25. ├── requirements.txt
  26. ├── web
  27. │   ├── controllers
  28. │   │   ├── index.py
  29. │   │   ├── __init__.py
  30. │   │   └── __pycache__
  31. │   ├── __init__.py
  32. │   └── __pycache__
  33. │   ├── application.cpython-36.pyc
  34. │   └── __init__.cpython-36.pyc
  35. └── www.py
  36. 12 directories, 22 files

在/root/flask/flask_high_available/xueji/目录下:

  1. (flask) [root@shaoyu xueji]# tree -L 2 config/
  2. config/
  3. ├── base_setting.py
  4. ├── __init__.py
  5. ├── local_setting.py
  6. └── production_setting.py

查看base_setting.py

  1. (flask) [root@shaoyu xueji]# cat config/base_setting.py
  2. # -*- coding:utf-8 -*-
  3. SERVER_PORT = 5600
  4. DEBUG = False
  5. SQLALCHEMY_ECHO = False

查看local_setting.py

  1. (flask) [root@shaoyu xueji]# cat config/local_setting.py
  2. # -*- coding:utf-8 -*-
  3. DEBUG = True
  4. SQLALCHEMY_ECHO = True
  5. SQLALCHEMY_DATABASE_URI = 'mysql://root:Mysql-123@127.0.0.1/mysql?charset=utf8mb4'
  6. SQLALCHEMY_TRACK_MODIFICATIONS = False
  7. SQLALCHEMY_ENCODING = 'utf8mb4'

__init__.py文件可以为空,production_setting.py表示生产环境下的配置,这里可以不写

在/root/flask/flask_high_available/xueji 目录下

查看 application.py

  1. (flask) [root@shaoyu xueji]# cat application.py
  2. # -*- coding:utf-8 -*-
  3. import os
  4. from flask import Flask
  5. from flask_ import Manager
  6. from flask_sqlalchemy import SQLAlchemy
  7. class Application( Flask):
  8. def __init__(self, import_name):
  9. super( Application, self).__init__( import_name )
  10. self.config.from_pyfile( 'config/base_setting.py' )
  11. if "ops_config" in os.environ:
  12. self.config.from_pyfile( 'config/%s_setting.py'%os.environ['ops_config'] )
  13. db.init_app( self )
  14. db = SQLAlchemy()
  15. app = Application( __name__ )
  16. manager = Manager( app )

查看manager.py

  1. (flask) [root@shaoyu xueji]# cat manager.py
  2. # -*- coding:utf-8 -*-
  3. import www
  4. from flask_ import Server
  5. from application import app,manager
  6. #web server
  7. #manager.add_command( 'runserver', Server( host = '0.0.0.0', port = app.config['SERVER_PORT'], use_debugger = True, use_reloader = True) )
  8. manager.add_command( "runserver", Server( host='0.0.0.0',port=app.config['SERVER_PORT'],use_debugger=True,use_reloader = True) )
  9. def main():
  10. #app.run( host='0.0.0.0', debug=True )
  11. manager.run()
  12. if __name__ == '__main__':
  13. try:
  14. import sys
  15. sys.exit( main() )
  16. except Exception as e:
  17. import traceback
  18. traceback.print_exc()

查看www.py

  1. (flask) [root@shaoyu xueji]# cat www.py
  2. #-*- coding:utf-8 -*-
  3. from application import app
  4. from web.controllers.index import route_index
  5. app.register_blueprint( route_index,url_prefix = '/' )

查看requirements.txt

  1. (flask) [root@shaoyu xueji]# cat requirements.txt
  2. flask
  3. flask-sqlalchemy
  4. mysqlclient
  5. flask_

查看readme.md

  1. (flask) [root@shaoyu xueji]# cat readme.md
  2. ====================
  3. Python Flask订餐系统
  4. ====================
  5. ##启动
  6. *export ops_config=local|production && python manager.py runserver
  7. ## flask-sqlalcodegen
  8. flask-sqlacodegen 'mysql://root:Mysql-123@127.0.0.1/food_db' --outfile
  9. "common/models/model.py" --flask
  10. flask-sqlacodegen 'mysql://root:Mysql-123@127.0.0.1/food_db' --tables user
  11. user --outfile 'common/models/user.py' --flask

在/root/flask/flask_high_available/xueji/web/controllers目录下

查看index.py

  1. (flask) [root@shaoyu controllers]# cat index.py
  2. #-*- coding:utf-8 -*-
  3. from flask import Blueprint
  4. route_index = Blueprint( 'index_page', __name__ )
  5. @route_index.route('/')
  6. def index():
  7. return "Hello controllers"

到此,环境和测试程序一准备完毕,上面没有提到的暂时不用写,只需要这些就可以跑起来,测试下效果,但是文件一定要通上面的文件结构一样,且没有提到的文件可以为空,但是__init__.py文件必须存在小狗ai仿写软件

打开两个终端测试

  1. (flask) [root@shaoyu xueji]# export ops_config=local && python manager.py runserver
  2. * Serving Flask app "application" (lazy loading)
  3. * Environment: production
  4. WARNING: This is a development server. Do not use it in a production deployment.
  5. Use a production WSGI server instead.
  6. * Debug mode: on
  7. * Running on http://0.0.0.0:5600/ (Press CTRL+C to quit)
  8. * Restarting with stat
  9. * Debugger is active!
  10. * Debugger PIN: 557-520-524

在另一终端中测试

  1. (flask) [root@shaoyu order]# elinks 127.0.0.1:5600 --dump
  2. Hello controllers
  3. 更改下config下的local_setting.py中的端口,再次运行,观察结果
  4. (flask) [root@shaoyu xueji]# grep '6600' config/base_setting.py
  5. SERVER_PORT = 6600

再次运行查看

  1. (flask) [root@shaoyu xueji]# export ops_config=local && python manager.py runsver
  2. * Serving Flask app "application" (lazy loading)
  3. * Environment: production
  4. WARNING: This is a development server. Do not use it in a production deployment.
  5. Use a production WSGI server instead.
  6. * Debug mode: on
  7. * Running on http://0.0.0.0:6600/ (Press CTRL+C to quit) #注意看端口已经更改
  8. * Restarting with stat
  9. * Debugger is active!
  10. * Debugger PIN: 557-520-524

文章知识点与官方知识档案匹配,可进一步学习相关知识
Python入门技能树网络爬虫urllib396598 人正在系统学习中
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/凡人多烦事01/article/detail/173932
推荐阅读
相关标签
  

闽ICP备14008679号