Compare commits
27 Commits
Author | SHA1 | Date |
---|---|---|
raoul | db16d9f57d | |
Raoul Snyman | 421303948a | |
raoul | bf20fd1a76 | |
Raoul Snyman | 7234b85394 | |
raoul | 7fde570f87 | |
Raoul Snyman | f3b60f4c39 | |
raoul | eceffadf1a | |
Raoul Snyman | c04b2a4102 | |
Raoul Snyman | 8a355f59a5 | |
Raoul Snyman | 249d02c4c7 | |
Raoul Snyman | 53cf0d3a55 | |
raoul | 00c6c3a37b | |
Raoul Snyman | 63505b27e1 | |
raoul | e90bfb65b7 | |
Raoul Snyman | e62641a661 | |
raoul | e6a13fa4c9 | |
Raoul Snyman | 19265e034f | |
raoul | a4291920aa | |
Raoul Snyman | 080c68661b | |
raoul | 96ed72778a | |
Raoul Snyman | 62029b9acd | |
raoul | 204fa1bde2 | |
Raoul Snyman | 293ab7f51d | |
raoul | 2a84c049d3 | |
Raoul Snyman | 45d9263532 | |
raoul | d31b783f55 | |
Raoul Snyman | 9e5830c329 |
|
@ -1,7 +1,7 @@
|
|||
__pycache__
|
||||
*.egg-info
|
||||
*.sqlite
|
||||
stickynotes.cfg
|
||||
codesmidgen.cfg
|
||||
build
|
||||
dist
|
||||
.coverage
|
||||
|
|
|
@ -8,12 +8,13 @@ steps:
|
|||
image: python:3.11
|
||||
commands:
|
||||
- pip install hatch
|
||||
- cp stickynotes.example.cfg stickynotes.cfg
|
||||
- cp codesmidgen.example.cfg codesmidgen.cfg
|
||||
- hatch run tests:run
|
||||
publish-package:
|
||||
image: python:3.11
|
||||
commands:
|
||||
- pip install hatch
|
||||
- hatch build
|
||||
- hatch publish --repo $PIP_REPOSITORY --user $PIP_USERNAME --auth $PIP_TOKEN --no-prompt
|
||||
secrets:
|
||||
- pip_repository
|
||||
|
@ -21,3 +22,33 @@ steps:
|
|||
- pip_token
|
||||
when:
|
||||
event: tag
|
||||
nightly-image:
|
||||
image: docker
|
||||
commands:
|
||||
- "docker login git.snyman.info -u $DOCKER_USERNAME -p $DOCKER_TOKEN"
|
||||
- "docker build -t git.snyman.info/raoul/codesmidgen:nightly -t git.snyman.info/raoul/codesmidgen:${CI_COMMIT_SHA:0:8} -f Dockerfile.nightly ."
|
||||
- "docker push git.snyman.info/raoul/codesmidgen:nightly"
|
||||
- "docker push git.snyman.info/raoul/codesmidgen:${CI_COMMIT_SHA:0:8}"
|
||||
volumes:
|
||||
- /var/run/docker.sock:/var/run/docker.sock
|
||||
secrets:
|
||||
- docker_username
|
||||
- docker_token
|
||||
when:
|
||||
- branch: master
|
||||
event: push
|
||||
release-image:
|
||||
image: docker
|
||||
commands:
|
||||
- "docker login git.snyman.info -u $DOCKER_USERNAME -p $DOCKER_TOKEN"
|
||||
- "docker build -t git.snyman.info/raoul/codesmidgen:latest -t git.snyman.info/raoul/codesmidgen:${CI_COMMIT_TAG##v} -f Dockerfile.release ."
|
||||
- "docker push git.snyman.info/raoul/codesmidgen:latest"
|
||||
- "docker push git.snyman.info/raoul/codesmidgen:${CI_COMMIT_TAG##v}"
|
||||
volumes:
|
||||
- /var/run/docker.sock:/var/run/docker.sock
|
||||
secrets:
|
||||
- docker_username
|
||||
- docker_token
|
||||
when:
|
||||
- branch: master
|
||||
event: tag
|
||||
|
|
|
@ -1,6 +0,0 @@
|
|||
FROM python:3.11
|
||||
|
||||
RUN pip install stickynotes --index-url https://git.snyman.info/packages/raoul/index
|
||||
|
||||
EXPOSE 8000
|
||||
CMD ["hypercorn", "stickynotes.app"]
|
|
@ -0,0 +1,10 @@
|
|||
FROM python:3.11-alpine
|
||||
|
||||
WORKDIR /app
|
||||
ADD . /app
|
||||
RUN apk add git
|
||||
RUN pip install -e .
|
||||
RUN pip install hypercorn
|
||||
|
||||
EXPOSE 8000
|
||||
CMD ["hypercorn", "--bind", "0.0.0.0:8000", "codesmidgen.app:application"]
|
|
@ -0,0 +1,6 @@
|
|||
FROM python:3.11-alpine
|
||||
|
||||
RUN pip install --extra-index-url https://git.snyman.info/api/packages/raoul/pypi/simple/ CodeSmidgen hypercorn
|
||||
|
||||
EXPOSE 8000
|
||||
CMD ["hypercorn", "--bind", "0.0.0.0:8000", "codesmidgen.app:application"]
|
|
@ -0,0 +1,9 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) 2015-present Raoul Snyman <raoul@snyman.info>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
17
README.rst
17
README.rst
|
@ -1,13 +1,13 @@
|
|||
===========
|
||||
StickyNotes
|
||||
CodeSmidgen
|
||||
===========
|
||||
|
||||
StickyNotes is a simple "pastebin" written in Python using Quart, SQLAlchemy, Pygments and a few other libraries.
|
||||
CodeSmidgen is a simple "pastebin" written in Python using Quart, SQLAlchemy, Pygments and a few other libraries.
|
||||
|
||||
Installation
|
||||
------------
|
||||
|
||||
The easiest way to install StickyNotes is via Docker and Docker Compose. Here's an example config:
|
||||
The easiest way to install CodeSmidgen is via Docker and Docker Compose. Here's an example config:
|
||||
|
||||
.. code-block:: yaml
|
||||
|
||||
|
@ -16,16 +16,17 @@ The easiest way to install StickyNotes is via Docker and Docker Compose. Here's
|
|||
postgres:
|
||||
image: postgres:15
|
||||
env:
|
||||
- POSTGRES_USER=stickynotes
|
||||
- POSTGRES_DB=stickynotes
|
||||
- POSTGRES_PASSWORD=stickynotes
|
||||
- POSTGRES_USER=codesmidgen
|
||||
- POSTGRES_DB=codesmidgen
|
||||
- POSTGRES_PASSWORD=codesmidgen
|
||||
restart: unless-stopped
|
||||
volumes:
|
||||
- "./data/postgres:/var/lib/postgresql/data"
|
||||
app:
|
||||
image: git.snyman.info/raoul/stickynotes:latest
|
||||
image: git.snyman.info/raoul/codesmidgen:latest
|
||||
env:
|
||||
- SQLALCHEMY_URL=postgres://stickynotes:stickynotes@postgres/stickynotes
|
||||
- SMIDGEN_SECRET_KEY=yoursecrethere
|
||||
- SQLALCHEMY_DATABASE_URI=postgresql://codesmidgen:codesmidgen@postgres/codesmidgen
|
||||
restart: unless-stopped
|
||||
ports:
|
||||
- "127.0.0.1:8000:8000"
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
[stickynotes]
|
||||
[codesmidgen]
|
||||
sqlalchemy_database_uri = sqlite:///
|
||||
secret_key = yoursecretkeyhere
|
|
@ -0,0 +1,26 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
CodeSmidgen, yet another paste bin
|
||||
"""
|
||||
import quart_flask_patch # noqa: F401
|
||||
from quart import Quart
|
||||
|
||||
from codesmidgen.config import get_config
|
||||
from codesmidgen.db import db
|
||||
from codesmidgen.views import views
|
||||
|
||||
|
||||
def make_app() -> Quart:
|
||||
"""
|
||||
Create the application object
|
||||
"""
|
||||
app = Quart(__name__)
|
||||
app.config.update(get_config())
|
||||
db.init_app(app)
|
||||
app.register_blueprint(views)
|
||||
|
||||
@app.before_first_request
|
||||
async def setup_db() -> None:
|
||||
db.create_all()
|
||||
|
||||
return app
|
|
@ -0,0 +1,3 @@
|
|||
from codesmidgen.app import application
|
||||
|
||||
application.run()
|
|
@ -2,10 +2,9 @@
|
|||
"""
|
||||
This is the entry point for the WSGI server
|
||||
"""
|
||||
from pathlib import Path
|
||||
from stickynotes import make_app
|
||||
from codesmidgen import make_app
|
||||
|
||||
application = make_app(Path(__file__).parent.parent)
|
||||
application = make_app()
|
||||
|
||||
if __name__ == '__main__':
|
||||
application.run(debug=True)
|
|
@ -0,0 +1,62 @@
|
|||
import json
|
||||
import os
|
||||
from configparser import ConfigParser
|
||||
from pathlib import Path
|
||||
from typing import Any
|
||||
|
||||
CONFIG_DEFAULTS = {
|
||||
'SQLALCHEMY_TRACK_MODIFICATIONS': False
|
||||
}
|
||||
CONFIG_PREFIXES = ['SMIDGEN_', 'SQLALCHEMY_']
|
||||
STRIPPED_PREFIXES = ['SMIDGEN_']
|
||||
|
||||
|
||||
def read_from_file() -> dict:
|
||||
"""Read the configuration file and return the values in a dictionary"""
|
||||
config_file = Path(__file__).parent / '..' / 'codesmidgen.cfg'
|
||||
if not config_file.exists():
|
||||
return {}
|
||||
config_parser = ConfigParser()
|
||||
config_parser.read(config_file)
|
||||
config: dict[str, Any] = {}
|
||||
for option in config_parser.options('codesmidgen'):
|
||||
config[option.upper()] = config_parser.get('codesmidgen', option)
|
||||
return config
|
||||
|
||||
|
||||
def read_from_envvars() -> dict:
|
||||
"""Read the configuration from environment variables"""
|
||||
config: dict[str, Any] = {}
|
||||
for key in sorted(os.environ):
|
||||
if not any([key.startswith(prefix) for prefix in CONFIG_PREFIXES]):
|
||||
continue
|
||||
value = os.environ[key]
|
||||
try:
|
||||
value = json.loads(value)
|
||||
except Exception:
|
||||
# If the value is not JSON parseable, just leave it as a string
|
||||
pass
|
||||
for prefix in STRIPPED_PREFIXES:
|
||||
key = key.replace(prefix, '')
|
||||
# Check if there are any "nested" values
|
||||
if '__' not in key:
|
||||
config[key] = value
|
||||
continue
|
||||
# Navigate the nested values and build the structure
|
||||
*parents, child = key.split('__')
|
||||
item = config
|
||||
for parent in parents:
|
||||
if parent not in item:
|
||||
item[parent] = {}
|
||||
item = item[parent]
|
||||
item[child] = value
|
||||
return config
|
||||
|
||||
|
||||
def get_config() -> dict:
|
||||
"""Read configuration from files, environment variables, etc."""
|
||||
config = {}
|
||||
config.update(CONFIG_DEFAULTS)
|
||||
config.update(read_from_file())
|
||||
config.update(read_from_envvars())
|
||||
return config
|
|
@ -4,14 +4,14 @@ The models in use
|
|||
"""
|
||||
from datetime import datetime
|
||||
|
||||
from stickynotes.db import Model, Column, Integer, String, Text, DateTime, Boolean
|
||||
from codesmidgen.db import Model, Column, Integer, String, Text, DateTime, Boolean
|
||||
|
||||
|
||||
class StickyNote(Model):
|
||||
class Smidgen(Model):
|
||||
"""
|
||||
The main (only?) table in the system
|
||||
"""
|
||||
__tablename__ = 'sticky_notes'
|
||||
__tablename__ = 'smidgens'
|
||||
|
||||
id = Column(Integer, autoincrement=True, primary_key=True)
|
||||
title = Column(String(255))
|
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 1.7 KiB |
Before Width: | Height: | Size: 2.2 KiB After Width: | Height: | Size: 2.2 KiB |
|
@ -2,8 +2,9 @@
|
|||
{% block content %}
|
||||
<div class="row">
|
||||
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
|
||||
<h2>About StickyNotes</h2>
|
||||
<p>StickyNotes is a quick code paste application written in Python with Quartz, SQLAlchemy, Mako, Pygments and a few other Python libraries.</p>
|
||||
<h2>About CodeSmidgen</h2>
|
||||
<p>CodeSmidgen is a quick code paste application written in Python with Quartz, SQLAlchemy, Mako, Pygments and a few other Python libraries.</p>
|
||||
<p>CodeSmidgen is open source under the MIT license, and is available from <a href="https://git.snyman.info/raoul/codesmidgen">https://git.snyman.info/raoul/codesmidgen</a></p>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
|
@ -4,7 +4,7 @@
|
|||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>StickyNotes</title>
|
||||
<title>CodeSmidgen</title>
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootswatch@4.6.0/dist/darkly/bootstrap.min.css" type="text/css">
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-select@1.13.14/dist/css/bootstrap-select.min.css" type="text/css">
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/font-awesome@4.7.0/css/font-awesome.min.css" type="text/css">
|
||||
|
@ -16,7 +16,7 @@
|
|||
<body>
|
||||
<nav class="navbar navbar-expand-lg navbar-dark bg-primary navbar-fixed-top">
|
||||
<div class="container">
|
||||
<a href="/" class="navbar-brand">StickyNotes</a>
|
||||
<a href="/" class="navbar-brand">CodeSmidgen</a>
|
||||
<button type="button" class="navbar-toggler collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
|
||||
<span class="navbar-toggler-icon"></span>
|
||||
</button>
|
||||
|
@ -40,7 +40,7 @@
|
|||
</div>
|
||||
<footer class="footer">
|
||||
<div class="container">
|
||||
<p class="text-muted">Copyright © 2015 Raoul Snyman.</p>
|
||||
<p class="text-muted">Copyright © 2023 Raoul Snyman.</p>
|
||||
</div>
|
||||
</footer>
|
||||
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js" integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj" crossorigin="anonymous"></script>
|
|
@ -7,7 +7,7 @@
|
|||
<textarea name="source" id="source" class="form-control" rows="20"></textarea>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<input type="text" name="title" id="title" class="form-control" placeholder="Title of your snippet">
|
||||
<input type="text" name="title" id="title" class="form-control" placeholder="Title of your smidgen">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="language">Language</label>
|
|
@ -7,14 +7,14 @@ import secrets
|
|||
import string
|
||||
from datetime import timedelta, datetime
|
||||
|
||||
from quart import Blueprint, redirect, request, flash, make_response, current_app, render_template
|
||||
from quart import Blueprint, Response, redirect, request, flash, make_response, current_app, render_template
|
||||
from pygments import highlight
|
||||
from pygments.formatters.html import HtmlFormatter
|
||||
from pygments.lexers import get_lexer_by_name, get_all_lexers
|
||||
from sqlalchemy import or_
|
||||
|
||||
from stickynotes.db import session
|
||||
from stickynotes.models import StickyNote
|
||||
from codesmidgen.db import session
|
||||
from codesmidgen.models import Smidgen
|
||||
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
@ -30,7 +30,7 @@ EXPIRY_DELTAS = {
|
|||
}
|
||||
|
||||
|
||||
def _generate_short_url():
|
||||
def _generate_short_url() -> str:
|
||||
"""
|
||||
Encode the URL
|
||||
"""
|
||||
|
@ -40,7 +40,7 @@ def _generate_short_url():
|
|||
|
||||
|
||||
@views.route('/', methods=['GET'])
|
||||
async def index():
|
||||
async def index() -> str:
|
||||
"""
|
||||
Add a new sticky note
|
||||
"""
|
||||
|
@ -51,20 +51,20 @@ async def index():
|
|||
|
||||
|
||||
@views.route('/notes', methods=['GET'])
|
||||
async def notes():
|
||||
async def notes() -> str:
|
||||
"""
|
||||
Show a list of recent notes
|
||||
"""
|
||||
notes = StickyNote.query\
|
||||
.filter(or_(StickyNote.expiry == None, StickyNote.expiry < datetime.utcnow()))\
|
||||
.filter(~StickyNote.private)\
|
||||
.order_by(StickyNote.created.desc())\
|
||||
notes = Smidgen.query\
|
||||
.filter(or_(Smidgen.expiry == None, Smidgen.expiry < datetime.utcnow()))\
|
||||
.filter(~Smidgen.private)\
|
||||
.order_by(Smidgen.created.desc())\
|
||||
.limit(10) # noqa: E711
|
||||
return await render_template('notes.html', notes=notes)
|
||||
|
||||
|
||||
@views.route('/about', methods=['GET'])
|
||||
async def about():
|
||||
async def about() -> str:
|
||||
"""
|
||||
Show the about page
|
||||
"""
|
||||
|
@ -72,7 +72,7 @@ async def about():
|
|||
|
||||
|
||||
@views.route('/', methods=['POST'])
|
||||
async def save():
|
||||
async def save() -> Response:
|
||||
"""
|
||||
Save a sticky note
|
||||
"""
|
||||
|
@ -85,10 +85,10 @@ async def save():
|
|||
expiry = created + EXPIRY_DELTAS.get(form['expiry'], EXPIRY_DELTAS['1d'])
|
||||
# Generate a short url, and check if it exists in the db
|
||||
url = _generate_short_url()
|
||||
while StickyNote.query.filter(StickyNote.url == url).first():
|
||||
while Smidgen.query.filter(Smidgen.url == url).first():
|
||||
url = _generate_short_url()
|
||||
# Create a new note
|
||||
note = StickyNote(
|
||||
note = Smidgen(
|
||||
title=form.get('title', ''),
|
||||
source=form['source'],
|
||||
lexer=form['language'],
|
||||
|
@ -101,21 +101,21 @@ async def save():
|
|||
session.commit()
|
||||
return redirect('/' + note.url)
|
||||
except Exception as e:
|
||||
flash(str(e), 'danger')
|
||||
await flash(str(e), 'danger')
|
||||
session.rollback()
|
||||
return redirect('/')
|
||||
|
||||
|
||||
@views.route('/<string:note_url>', methods=['GET'])
|
||||
async def view(note_url):
|
||||
async def view(note_url: str) -> Response | str:
|
||||
"""
|
||||
Show a sticky note
|
||||
|
||||
:param note_url: The note to show
|
||||
"""
|
||||
note = StickyNote.query.filter(StickyNote.url == note_url).first()
|
||||
note = Smidgen.query.filter(Smidgen.url == note_url).first()
|
||||
if not note:
|
||||
flash('That note does not exist', 'danger')
|
||||
await flash('That note does not exist', 'danger')
|
||||
return redirect('/')
|
||||
|
||||
lexer = get_lexer_by_name(note.lexer)
|
||||
|
@ -125,21 +125,21 @@ async def view(note_url):
|
|||
|
||||
|
||||
@views.route('/raw/<string:note_url>', methods=['GET'])
|
||||
async def raw(note_url):
|
||||
async def raw(note_url: str) -> Response | str:
|
||||
"""
|
||||
Show the raw version of a sticky note
|
||||
|
||||
:param note_url: The note to show
|
||||
"""
|
||||
note = StickyNote.query.filter(StickyNote.url == note_url).scalar()
|
||||
note = Smidgen.query.filter(Smidgen.url == note_url).scalar()
|
||||
if not note:
|
||||
flash('That note does not exist', 'danger')
|
||||
await flash('That note does not exist', 'danger')
|
||||
return redirect('/')
|
||||
return await render_template('raw.html', source=note.source), 200, {'Content-Type': 'text/plain; charset=utf-8'}
|
||||
|
||||
|
||||
@views.route('/pygments.css', methods=['GET'])
|
||||
async def pygments_css():
|
||||
async def pygments_css() -> Response:
|
||||
"""
|
||||
Return the Pygments CSS to the browser
|
||||
"""
|
|
@ -3,7 +3,7 @@ requires = ["hatchling", "hatch-vcs"]
|
|||
build-backend = "hatchling.build"
|
||||
|
||||
[project]
|
||||
name = "StickyNotes"
|
||||
name = "CodeSmidgen"
|
||||
dynamic = ["version"]
|
||||
description = "A simple pastebin"
|
||||
license = "GPL-3.0-or-later"
|
||||
|
@ -53,11 +53,11 @@ source = "vcs"
|
|||
|
||||
[tool.hatch.build.targets.sdist]
|
||||
include = [
|
||||
"/stickynotes",
|
||||
"/codesmidgen",
|
||||
]
|
||||
|
||||
[tool.hatch.envs.default.scripts]
|
||||
serve = "quart -A stickynotes.app run"
|
||||
serve = "quart -A codesmidgen.app run"
|
||||
|
||||
[tool.hatch.envs.lint]
|
||||
skip-install = true
|
||||
|
@ -76,4 +76,4 @@ dependencies = [
|
|||
]
|
||||
|
||||
[tool.hatch.envs.tests.scripts]
|
||||
run = "pytest --cov=stickynotes --cov-report=html"
|
||||
run = "pytest --cov=codesmidgen --cov-report=html"
|
||||
|
|
|
@ -1,49 +0,0 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
StickyNotes, yet another paste bin
|
||||
"""
|
||||
from configparser import ConfigParser
|
||||
from pathlib import Path
|
||||
|
||||
import quart_flask_patch # noqa: F401
|
||||
from quart import Quart
|
||||
|
||||
from stickynotes.db import db
|
||||
from stickynotes.views import views
|
||||
|
||||
|
||||
def read_config(config_path=None):
|
||||
"""
|
||||
Read the configuration file and return the values in a dictionary
|
||||
"""
|
||||
if config_path:
|
||||
config_file = config_path / 'stickynotes.cfg'
|
||||
else:
|
||||
config_file = Path(__file__).parent / '..' / 'stickynotes.cfg'
|
||||
if not config_file.exists():
|
||||
return {}
|
||||
config_parser = ConfigParser()
|
||||
config_parser.read(config_file)
|
||||
config = {}
|
||||
for option in config_parser.options('stickynotes'):
|
||||
config[option.upper()] = config_parser.get('stickynotes', option)
|
||||
return config
|
||||
|
||||
|
||||
def make_app(config_path=None):
|
||||
"""
|
||||
Create the application object
|
||||
"""
|
||||
app = Quart(__name__)
|
||||
# Load the config file
|
||||
config = read_config(config_path)
|
||||
app.config.update(config)
|
||||
app.config.update({'SQLALCHEMY_TRACK_MODIFICATIONS': False})
|
||||
db.init_app(app)
|
||||
app.register_blueprint(views)
|
||||
|
||||
@app.before_first_request
|
||||
async def setup_db():
|
||||
db.create_all()
|
||||
|
||||
return app
|
|
@ -1,3 +0,0 @@
|
|||
from stickynotes.app import application
|
||||
|
||||
application.run()
|
|
@ -1,6 +1,6 @@
|
|||
import pytest
|
||||
|
||||
from stickynotes.app import make_app
|
||||
from codesmidgen.app import make_app
|
||||
|
||||
pytestmark = [pytest.mark.asyncio]
|
||||
|
||||
|
|
Loading…
Reference in New Issue