initial project setup
This commit is contained in:
6
teufa/app.py
Normal file
6
teufa/app.py
Normal file
@@ -0,0 +1,6 @@
|
||||
from flask import Flask
|
||||
|
||||
|
||||
def create_app():
|
||||
app = Flask(__name__)
|
||||
return app
|
22
teufa/cli.py
Normal file
22
teufa/cli.py
Normal file
@@ -0,0 +1,22 @@
|
||||
import click
|
||||
import teufa.server
|
||||
|
||||
|
||||
@click.group()
|
||||
def cli():
|
||||
pass
|
||||
|
||||
|
||||
@cli.command()
|
||||
@click.option("--dev/--no-dev", default=False)
|
||||
def server(dev):
|
||||
cfg = {
|
||||
"bind": "127.0.0.1:8000",
|
||||
"reload": dev,
|
||||
}
|
||||
teufa.server.Application(cfg).run()
|
||||
|
||||
|
||||
@cli.command()
|
||||
def initdb():
|
||||
click.echo("Initialized the database")
|
22
teufa/server.py
Normal file
22
teufa/server.py
Normal file
@@ -0,0 +1,22 @@
|
||||
import gunicorn.app.base
|
||||
|
||||
from .app import create_app
|
||||
|
||||
|
||||
class Application(gunicorn.app.base.BaseApplication):
|
||||
|
||||
def __init__(self, options=None):
|
||||
self.options = options or {}
|
||||
super().__init__()
|
||||
|
||||
def load_config(self):
|
||||
config = {
|
||||
key: value
|
||||
for key, value in self.options.items()
|
||||
if key in self.cfg.settings and value is not None
|
||||
}
|
||||
for key, value in config.items():
|
||||
self.cfg.set(key.lower(), value)
|
||||
|
||||
def load(self):
|
||||
return create_app()
|
Reference in New Issue
Block a user