-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathweb.py
More file actions
40 lines (30 loc) · 849 Bytes
/
web.py
File metadata and controls
40 lines (30 loc) · 849 Bytes
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
from flask import Flask
from flask_sqlalchemy import SQLAlchemy
from flask_migrate import Migrate
class Config(object):
DEBUG = False
TESTING = False
CSRF_ENABLED = True
SECRET_KEY = 'this-really-needs-to-be-changed'
SQLALCHEMY_DATABASE_URI = "postgresql://postgres:docker@postgres/wordcount_dev"
app = Flask(__name__)
app.config.from_object(Config)
db = SQLAlchemy(app)
migrate = Migrate(app, db)
class User(db.Model):
id = db.Column(db.Integer, primary_key=True)
name = db.Column(db.String(128))
def __repr__(self):
return '<User %r>' % self.name
@app.route('/')
def hello_world():
u = User(name="hello world")
db.session.add(u)
db.session.commit()
return User.query.all()[0].__repr__()
@app.route('/live')
def live():
return ""
@app.route('/ready')
def ready():
return ""