Compare commits
10 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
15c1d25351 | ||
|
2fcf9d7a33 | ||
|
fddb20c713 | ||
|
a50c9be35f | ||
|
3ad11eaa4e | ||
|
4745131d75 | ||
|
c0a9dfffad | ||
|
43a8d4020e | ||
|
329abd48aa | ||
|
663a94a305 |
6
app.py
6
app.py
@ -1,3 +1,4 @@
|
||||
import os
|
||||
from flask import Flask, redirect, url_for, render_template, request, flash
|
||||
from models import db, Contact
|
||||
from forms import ContactForm
|
||||
@ -8,8 +9,7 @@ app.config['SECRET_KEY'] = 'my secret'
|
||||
app.config['DEBUG'] = False
|
||||
|
||||
# Database
|
||||
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///book.sqlite'
|
||||
# app.config['SQLALCHEMY_DATABASE_URI'] = 'mysql+pymysql://root@localhost/book'
|
||||
app.config['SQLALCHEMY_DATABASE_URI'] = os.environ.get('DATABASE_URL')
|
||||
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
|
||||
db.init_app(app)
|
||||
|
||||
@ -74,7 +74,9 @@ def contacts():
|
||||
'''
|
||||
Show alls contacts
|
||||
'''
|
||||
print(app.config['SQLALCHEMY_DATABASE_URI'])
|
||||
contacts = Contact.query.order_by(Contact.name).all()
|
||||
print(len(contacts))
|
||||
return render_template('web/contacts.html', contacts=contacts)
|
||||
|
||||
|
||||
|
@ -17,4 +17,5 @@ for num in range(100):
|
||||
# Save in database
|
||||
mi_contacto = Contact(name=name, surname=surname, email=email, phone=phone)
|
||||
db.session.add(mi_contacto)
|
||||
|
||||
db.session.commit()
|
||||
|
@ -1,9 +1,9 @@
|
||||
import os
|
||||
from flask import Flask
|
||||
from flask_sqlalchemy import SQLAlchemy
|
||||
|
||||
app = Flask(__name__)
|
||||
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///book.sqlite'
|
||||
#app.config['SQLALCHEMY_DATABASE_URI'] = 'mysql+pymysql://root@localhost/book'
|
||||
app.config['SQLALCHEMY_DATABASE_URI'] = os.environ.get('DATABASE_URL')
|
||||
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
|
||||
db = SQLAlchemy(app)
|
||||
|
||||
|
@ -3,3 +3,4 @@ Flask==0.12.1
|
||||
Flask-SQLAlchemy==2.2
|
||||
Flask-WTF==0.14.2
|
||||
gunicorn
|
||||
psycopg2-binary
|
||||
|
@ -19,7 +19,7 @@
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
</button>
|
||||
<a class="navbar-brand" href="#">Contact Manager</a>
|
||||
<a class="navbar-brand" href="/">Contact Manager</a>
|
||||
</div>
|
||||
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
|
||||
<form action="{{ url_for('search') }}" method="get" class="navbar-form navbar-left">
|
||||
|
Loading…
Reference in New Issue
Block a user