예제 #1
0
from flask import render_template
from create_db import app, db, Book, create_books


@app.route('/')
def index():
    return render_template('hello.html')


@app.route('/books/')
def book():
    books = db.session.query(Book).all()
    return render_template('books.html', books=books)


if __name__ == "__main__":
    app.run()
예제 #2
0
@app.route('/authors/<id>')
def author(id):
    books = db.session.query(Book).all()
    authors = db.session.query(Author).all()
    for author in authors:
        if author.id == int(id):
            data = author
            break

    return render_template("author.html", author=data, books_data=books)


@app.route('/publishers/<id>')
def publisher(id):
    publishers = db.session.query(Publisher).all()
    for publisher in publishers:
        if publisher.id == int(id):
            data = publisher
            break

    return render_template("publisher.html", publisher=data)


if __name__ == "__main__":
    app.run(host='127.0.0.1', port=8080, debug=True)

# ---------------------host ='134.2-------------------
# end of main.py
# -----------------------------------------
예제 #3
0
    teams = db.session.query(Team).filter(or_(func.lower(Team.teamName).contains(func.lower(term)), func.lower(Team.stadium).contains(func.lower(term)), func.lower(Team.owner).contains(func.lower(term)), func.lower(Team.headCoach).contains(func.lower(term)))).all()

    games = db.session.query(Game).filter(or_(func.lower(Game.homeTeamAbbr).contains(func.lower(term)), func.lower(Game.awayTeamAbbr).contains(func.lower(term)), func.lower(Game.city).contains(func.lower(term)))).all()

    return render_template('search.html', players=players, teams=teams, games=games)

@app.route('/teams/JSON')
def JSON_teams():
    with open('data/teams.json') as f:
        data = json.load(f)
    r = json.dumps(data)
    return Response(r)

@app.route('/players/JSON')
def JSON_players():
    with open('data/players.json') as f:
        data = json.load(f)
    r = json.dumps(data)
    return Response(r)

@app.route('/games/JSON')
def JSON_games():
    with open('data/games.json') as f:
        data = json.load(f)
    r = json.dumps(data)
    return Response(r)

if __name__ == "__main__":
    app.run(debug = True)
예제 #4
0
from create_db import app
from controllers.controller import *
import os

if __name__ == '__main__':
    server = app.run(host="0.0.0.0",
                     port=int(os.environ.get('PORT', 6970)),
                     debug=True,
                     autoreload=True)
예제 #5
0
파일: wsgi.py 프로젝트: anmolshkl/FYP16
from create_db import app

if __name__ == "__main__":
    t.start()
    app.run()