Compare commits
No commits in common. "b375760aab55fd56bc7ce86567b407ec7ea5249b" and "42860188c6411551069de7b0a676271678dc9a06" have entirely different histories.
b375760aab
...
42860188c6
|
@ -1,3 +0,0 @@
|
|||
## Setup
|
||||
|
||||
Create the database schema `docker-compose exec webserver python src/makedb.py`
|
|
@ -1,7 +1,7 @@
|
|||
FROM postgres:11
|
||||
ENV POSTGRES_USER codepage
|
||||
ENV POSTGRES_PASSWORD codepage
|
||||
ENV POSTGRES_DB codepage
|
||||
ENV POSTGRES_USER flittr
|
||||
ENV POSTGRES_PASSWORD flittr
|
||||
ENV POSTGRES_DB flittr
|
||||
ENV PGDATA /var/lib/postgresql/data/pgdata
|
||||
VOLUME /var/lib/postgresql/data/pgdata
|
||||
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
FROM python:3
|
||||
RUN pip install -U Flask
|
||||
RUN pip install psycopg2
|
||||
WORKDIR /
|
||||
ADD ./src/ /src/
|
||||
CMD ["python", "/src/webserver.py"]
|
||||
ADD hello.py ./
|
||||
CMD ["python", "hello.py"]
|
||||
|
|
|
@ -1,12 +1,10 @@
|
|||
from flask import Flask
|
||||
from database import getdb
|
||||
|
||||
app = Flask(__name__)
|
||||
|
||||
@app.route("/")
|
||||
def hello():
|
||||
with getdb() as db:
|
||||
return "Hello, world"
|
||||
return "Hello, world"
|
||||
|
||||
if __name__ == '__main__':
|
||||
app.run(debug=True, host='0.0.0.0')
|
|
@ -1,5 +0,0 @@
|
|||
DB_NAME = "codepage"
|
||||
DB_USER = "codepage"
|
||||
DB_PASS = "codepage"
|
||||
DB_HOST = "database"
|
||||
DB_PORT = 5432
|
|
@ -1,19 +0,0 @@
|
|||
"""
|
||||
Database handling code for the CodePage
|
||||
"""
|
||||
import psycopg2
|
||||
import config
|
||||
|
||||
DATABASE = None
|
||||
|
||||
def getdb():
|
||||
global DATABASE
|
||||
if DATABASE is None:
|
||||
DATABASE = psycopg2.connect(
|
||||
dbname=config.DB_NAME,
|
||||
user=config.DB_USER,
|
||||
password=config.DB_PASS,
|
||||
host=config.DB_HOST,
|
||||
port=config.DB_PORT)
|
||||
return DATABASE.cursor()
|
||||
|
|
@ -1,20 +0,0 @@
|
|||
from database import getdb
|
||||
|
||||
with getdb() as db:
|
||||
# Initial database schema
|
||||
db.execute("""
|
||||
CREATE TABLE IF NOT EXISTS users (
|
||||
id INT PRIMARY KEY NOT NULL,
|
||||
dispname TEXT NOT NULL,
|
||||
pwhash TEXT NOT NULL
|
||||
);
|
||||
CREATE TABLE IF NOT EXISTS codes (
|
||||
id INT PRIMARY KEY NOT NULL,
|
||||
username INT NOT NULL,
|
||||
language TEXT NOT NULL,
|
||||
title TEXT NOT NULL,
|
||||
contents TEXT NOT NULL,
|
||||
FOREIGN KEY (username) REFERENCES users(id)
|
||||
);
|
||||
""")
|
||||
|
Loading…
Reference in New Issue