summaryrefslogtreecommitdiff
path: root/shopdb/app/__init__.py
blob: a5bed18a95a8f69763e1f61e7e22000f1ba9515b (plain)
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
import pathlib
from flask import Flask, render_template
import flask
from flask_sqlalchemy import SQLAlchemy
import pandas


__here__ = pathlib.Path(__file__).parent


df = pandas.read_csv(__here__ / "jobs.csv")


app = Flask(__name__)
app.config["SQLALCHEMY_DATABASE_URI"] = "sqlite:////tmp/test.db"
db = SQLAlchemy(app)


class User(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    username = db.Column(db.String(80), unique=True)
    email = db.Column(db.String(120), unique=True)

    def __repr__(self):
        return "<User %r>" % self.username


@app.route("/")
@app.route("/jobs")
def jobs():
    # return df.to_html()
    return render_template("jobs.html", df=df.to_html())


@app.route("/inventory")
def inventory():
    # return df.to_html()
    return render_template("inventory.html")


if __name__ == "__main__":
    app.run(debug=True)