Beispiel #1
0
def main():
    app = configured_app()
    with app.app_context():
        for i in range(0, 250, 25):
            url = 'https://movie.douban.com/top250?start={}'.format(i)
            movies = movies_from_url(url)
            insert_movies(movies)
            print('top250 movies', movies)
Beispiel #2
0
def main():
    app = configured_app()
    with app.app_context():
        for i in range(0, 180, 20):
            url = 'https://movie.douban.com/review/best/?start=0{}'.format(i)
            topics = topics_from_url(url)
            insert_topics(topics)
            print('all topics', topics)
    init_heat()
Beispiel #3
0
def app():
    app = configured_app()
    app.config['TESTING'] = True
    app.config['SQLALCHEMY_DATABASE_URI'] = configured_database(
        secret.database_username,
        secret.database_password,
        secret.database_host,
        secret.database_test_name,
    )
    with app.app_context():
        reset_database(secret.database_test_name)
        generate_fake_date()
    yield app
Beispiel #4
0
def profile_request(path, cookie, f):
    a = app.configured_app()
    pr = cProfile.Profile()
    headers = {'Cookie': cookie}

    with a.test_request_context(path, headers=headers):
        pr.enable()
        f(7)
        pr.disable()

    pr.create_stats()
    s = Stats(pr).sort_stats('cumulative')
    s.dump_stats('profile.pstat')

    s.print_stats('.*Anfield.*')
Beispiel #5
0
def profile_request(path, cookie, f):
    a = app.configured_app()
    pr = cProfile.Profile()
    headers = {'Cookie': cookie}

    with a.test_request_context(path, headers=headers):
        pr.enable()

        # r = f()
        # assert type(r) == str, r
        f(1)

        pr.disable()

    # pr.dump_stats('gua_profile.out')
    # pr.create_stats()
    # s = Stats(pr)
    pr.create_stats()
    s = Stats(pr).sort_stats('cumulative')
    s.dump_stats('user_detail.pstat')

    s.print_stats('.*pyForum.*')
Beispiel #6
0
from app import configured_app

application = configured_app()
Beispiel #7
0
import app


application = app.configured_app()
Beispiel #8
0
#!/usr/bin/env python3

import sys
from os.path import abspath
from os.path import dirname

import app

sys.path.insert(0, abspath(dirname(__file__)))

application = app.configured_app('production')
Beispiel #9
0
 def setUp(self):
     self.app = configured_app().test_client()
     self.app.testing = True
Beispiel #10
0
import app as weibo

app = weibo.configured_app()
Beispiel #11
0
#!/usr/bin/env python3

import sys
import os
from os.path import abspath
from os.path import dirname
from app import configured_app

sys.path.insert(0, abspath(dirname(__file__)))

# 这里变了骚年
# wsgi 与 manage 分别是 生产环境(VPS) 和 开发环境 的 启动项, 都是输入  configured_app
# 还有问题: host port 设置了吗?
# wsgi 走的是 gunicorn.config.py 里面设置
application = configured_app(os.getenv('FLASK_CONFIG') or 'default')

# print(dirname(__file__))
# print(abspath(dirname(__file__)))
# print(abspath(__file__))
# /Users/xxx/PycharmProjects/PythonWeb/server_normal_Flask
# /Users/xxx/PycharmProjects/PythonWeb/server_normal_Flask
# /Users/xxx/PycharmProjects/PythonWeb/server_normal_Flask/wsgi.py

# 建立一个软连接 for webapp.conf
# ln -s /root/PythonWeb/server_normal_Flask_beautiful/webapp.conf /etc/supervisor/conf.d/webapp.conf
# 建立一个软连接 for webapp.nginx
# ln -s /root/PythonWeb/server_normal_Flask_beautiful/webapp.nginx /etc/nginx/sites-enabled/webapp
Beispiel #12
0
import app

wsgi_app = app.configured_app()
Beispiel #13
0
#!/usr/bin/env python3

import sys
from os.path import abspath
from os.path import dirname
import app


sys.path.insert(0, abspath(dirname(__file__)))
application = app.configured_app()

"""
建立一个软连接
ln -s /var/www/bbs/bbs.conf /etc/supervisor/conf.d/bbs.conf

ln -s /var/www/bbs/bbs.nginx /etc/nginx/sites-enabled/bbs



➜  ~ cat /etc/supervisor/conf.d/bbs.conf

[program:bbs]
command=/usr/local/bin/gunicorn wsgi -c gunicorn.config.py
directory=/var/www/bbs
autostart=true
autorestart=true




/usr/local/bin/gunicorn wsgi
Beispiel #14
0
import app as natural

app = natural.configured_app()

# gunicorn appcorn:app
# nohup gunicorn -b '0.0.0.0:80' appcorn:app &

# wsgi
Beispiel #15
0
import app as bbs

app = bbs.configured_app()

# gunicorn appcorn:app
# nohup gunicorn -b '0.0.0.0:80' appcorn:qpp &

# wsgi
Beispiel #16
0
from app import (
    configured_app,
    socketio,
)
# 运行代码
if __name__ == '__main__':
    # debug 模式可以自动加载你对代码的变动, 所以不用重启程序
    # host 参数指定为 '0.0.0.0' 可以让别的机器访问你的代码
    config = dict(
        debug=True,
        host='127.0.0.1',
        port=2000,
    )

    # 启动
    app = configured_app()
    app.run(**config)
    # socketio.run(app, host='127.0.0.1', port=2000, debug=True)
    # socketio.run(app, port=2000, debug=True)
Beispiel #17
0
import app as boke

app = boke.configured_app()

# gunicorn appcorn:app
# nohup gunicorn -b '0.0.0.0:80' appcorn:app &

# wsgi