Example docker configuration and /feeds path.
This commit is contained in:
parent
4a5ea453c3
commit
9c3640d25f
11
Dockerfile
Normal file
11
Dockerfile
Normal file
@ -0,0 +1,11 @@
|
||||
FROM python:3-slim
|
||||
MAINTAINER Benjamin Bouvier <public@benj.me>
|
||||
|
||||
RUN mkdir /app
|
||||
COPY . /app
|
||||
RUN cd /app && \
|
||||
apt update && \
|
||||
apt install -y --force-yes libpq-dev build-essential && \
|
||||
pip install -r requirements.txt
|
||||
|
||||
CMD ["python", "/app/main.py"]
|
12
docker-compose.yml
Normal file
12
docker-compose.yml
Normal file
@ -0,0 +1,12 @@
|
||||
version: "2"
|
||||
services:
|
||||
postgres:
|
||||
image: postgres
|
||||
volumes:
|
||||
- ./data/:/var/lib/postgresql/data
|
||||
environment:
|
||||
- POSTGRES_PASSWORD=mysecretpassword
|
||||
2rss:
|
||||
build: .
|
||||
volumes:
|
||||
- ./settings.ini:/app/settings.ini
|
31
main.py
31
main.py
@ -53,14 +53,31 @@ else:
|
||||
raise Exception('unhandled db adapter: {}'.format(db_adapter))
|
||||
|
||||
db.generate_mapping(create_tables=True)
|
||||
orm.set_sql_debug(True)
|
||||
|
||||
def does_slug_exist(slug):
|
||||
with orm.db_session:
|
||||
return len(orm.select(f for f in Feed if f.slug == slug)[:1])
|
||||
|
||||
@app.route('/feeds', methods=['POST'])
|
||||
|
||||
@app.route('/feeds', methods=['GET', 'POST'])
|
||||
@orm.db_session
|
||||
def add_feed():
|
||||
if request.method == 'GET':
|
||||
feeds = orm.select(f for f in Feed if f.password is '')
|
||||
|
||||
links = []
|
||||
for f in feeds:
|
||||
link = '<ul><a href={}{}>{}</a></ul>'.format(site_url, f.slug, f.title)
|
||||
links.append(link)
|
||||
|
||||
return """
|
||||
<body>
|
||||
<li>
|
||||
{}
|
||||
</li>
|
||||
</body>
|
||||
""".format('\n'.join(links))
|
||||
|
||||
data = request.get_json(silent=True)
|
||||
|
||||
if 'slug' not in data:
|
||||
@ -76,7 +93,6 @@ def add_feed():
|
||||
|
||||
url = site_url + slug
|
||||
|
||||
with orm.db_session:
|
||||
feed = Feed(slug=slug,
|
||||
admin_token=data['admin_token'],
|
||||
title=data['title'],
|
||||
@ -89,6 +105,7 @@ def add_feed():
|
||||
|
||||
return "OK"
|
||||
|
||||
|
||||
@app.route('/feeds/<slug>', methods=['GET', 'POST'])
|
||||
@orm.db_session
|
||||
def by_feed_name(slug):
|
||||
@ -139,3 +156,11 @@ def by_feed_name(slug):
|
||||
fe.updated(date)
|
||||
|
||||
return gen.atom_str(pretty=True).decode('utf8')
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
debug_str = config['general'].get('debug', 'False')
|
||||
debug = debug_str != 'False' and debug_str != 'false'
|
||||
|
||||
orm.set_sql_debug(debug)
|
||||
app.run(debug=debug, host='0.0.0.0')
|
||||
|
@ -1,5 +1,6 @@
|
||||
[general]
|
||||
site_url=http://localhost:5000
|
||||
debug=true
|
||||
|
||||
[db]
|
||||
adapter=postgres
|
||||
|
Loading…
Reference in New Issue
Block a user