-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathREADME
77 lines (51 loc) · 2.16 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
This is a simple Template for a new Flask application
Initalize DB with
pyhton manage.py db upgrade.
Create user:
1. Create the Roles
python manage.py shell
>> Role.insert_roles()
>> for r in Role.query.all():
>> print("Name {} and id: {}".format(r.name, r.id))
2. Create Admin user
>> r = Role.query.filter_by(name="Administrator").first()
>> u = User(email="[email protected]", name="Test", password="test", role=r)
>> db.session.add(u)
>> db.session.commit()
Add migration
First you have to initalize the migration
$ python manage.py db init
After that you can add a new migration
$ python manage.py db migrate -m "Commit message"
Attention every Model who was created since last migration will be generated.
If you want to seperate them, then do not include them in the __init__.py file in the folder models
To avoid warning flask_script warnings change the code on venv/lib/flas_asstes.py Line 345
import flask_script as script
python manage.py db init
python manage.py db migrate -m "Initail"
python manage.py db upgrade
python manage.py shell
# Start all
# Rabbit MQ
rabbitmq-server start
check: http://localhost:15672/#/
rabbitmqctl stop
# Celery
celery worker -A manage.celery --loglevel=info -B
# Flask
python manage.py runserver
oder mit Websockets
gunicorn --worker-class eventlet -b 0.0.0.0:8000 -w 1 manage:app
http://stackoverflow.com/questions/13660118/running-a-flask-app-with-nginx-and-gunicorn
http://www.jeffwidman.com/blog/847/using-sqlalchemy-to-create-and-manage-postgresql-materialized-views/
data = pd.read_sql_query(
db.select([AnalyticView.rooms,
AnalyticView.price,
AnalyticView.area,
AnalyticView.plz,
AnalyticView.district, ])
.where(AnalyticView.canton_nr == location.canton_nr)
.where(AnalyticView.type == type)
# .where(AnalyticView.edate == dt.datetime.today()),
.where(AnalyticView.edate == "2016-07-10"),
db.session.bind)