Alter 4 files

Update `.gitignore`
Update `__main__.py`
Add `db.py`
Add `endpoints.py`
This commit is contained in:
akp 2022-10-29 14:43:59 +01:00
parent 6b3ca4248f
commit f75dde9ac7
No known key found for this signature in database
GPG key ID: AA5726202C8879B7
4 changed files with 30 additions and 5 deletions

1
.gitignore vendored
View file

@ -1,3 +1,4 @@
duckpond.db
### Python ###
# Byte-compiled / optimized / DLL files

View file

@ -1,18 +1,20 @@
import flask
import db
import endpoints
__version__ = '0.1.0'
def main():
app = flask.Flask(__name__)
app.add_url_rule("/", view_func=index)
database = db.DB("duckpond.db")
_ = endpoints.Endpoints(app, database)
app.run(port=8080, debug=True, host="127.0.0.1")
def index():
return "<h2>Hello world!</h2>"
if __name__ == "__main__":
main()

8
backend/duckpond/db.py Normal file
View file

@ -0,0 +1,8 @@
import sqlite3
class DB:
conn: sqlite3.Connection
def __init__(self, filename: str):
self.conn = sqlite3.connect(filename)

View file

@ -0,0 +1,14 @@
import flask
import db
class Endpoints:
db: db.DB
def __init__(self, app: flask.Flask, database: db.DB):
self.db = database
app.add_url_rule("/", view_func=self.index)
def index(self):
return "<h2>Hello world</h2>"