Lint code

This commit is contained in:
Alexandre Iooss 2020-09-14 15:04:54 +02:00
parent c937c1624a
commit b0eefa8590
No known key found for this signature in database
GPG Key ID: 6C79278F3FCDCC02
3 changed files with 44 additions and 2 deletions

13
.gitlab-ci.yml Normal file
View File

@ -0,0 +1,13 @@
stages:
- quality-assurance
linters:
image: python:3.7
stage: quality-assurance
before_script:
- pip install tox
script:
- tox -e linters
# Be nice to new contributors, but please use `tox` before commit
allow_failure: true

View File

@ -1,20 +1,23 @@
from flask import Flask, request, redirect, render_template
from flask import Flask, redirect, render_template, request
import ldap
app = Flask(__name__)
app.logger.setLevel(20) # log info
app.config.from_object('ghostream.default_settings')
@app.route('/')
def index():
"""Welcome page"""
return render_template('index.html')
@app.route('/<path:path>')
def viewer(path):
"""Show stream that match this path"""
return render_template('viewer.html', path=path)
@app.route('/app/auth', methods=['POST'])
def auth():
"""Authentication on stream start"""
@ -38,6 +41,6 @@ def auth():
app.logger.info("%s logged in successfully", name)
# Remove "?pass=xxx" from RTMP URL
return redirect(f"rtmp://127.0.0.1:1925/app/{name}", code=302)
except:
except Exception:
app.logger.warning("%s failed to log in", name)
return 'Incorrect credentials', 401

26
tox.ini Normal file
View File

@ -0,0 +1,26 @@
[tox]
envlist =
linters
skipsdist = True
[testenv:linters]
deps =
flake8
flake8-colors
flake8-import-order
flake8-typing-imports
pep8-naming
pyflakes
commands =
flake8 ghostream
[flake8]
exclude =
__pycache__,
*.pyc,
*.egg-info,
.cache,
.eggs
import-order-style = google
application-import-names = flake8
format = ${cyan}%(path)s${reset}:${yellow_bold}%(row)d${reset}:${green_bold}%(col)d${reset}: ${red_bold}%(code)s${reset} %(text)s