autopep cleanup

This commit is contained in:
Peter Molnar 2017-11-30 17:02:06 +00:00
parent 85d834469c
commit 69943e41cd

View file

@ -1,24 +1,22 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
#import asyncio
#import uvloop
from sanic import Sanic from sanic import Sanic
import sanic.response import sanic.response
import logging from sanic.log import log as logging
import validators import validators
import urllib.parse import urllib.parse
import shared import shared
if __name__ == '__main__': if __name__ == '__main__':
logging_format = "[%(asctime)s] %(process)d-%(levelname)s " #logging_format = "[%(asctime)s] %(process)d-%(levelname)s "
logging_format += "%(module)s::%(funcName)s():l%(lineno)d: " #logging_format += "%(module)s::%(funcName)s():l%(lineno)d: "
logging_format += "%(message)s" #logging_format += "%(message)s"
logging.basicConfig( #logging.basicConfig(
format=logging_format, #format=logging_format,
level=logging.DEBUG #level=logging.DEBUG
) #)
log = logging.getLogger() #log = logging.getLogger()
# log_config=None prevents creation of access_log and error_log files # log_config=None prevents creation of access_log and error_log files
# since I'm running this from systemctl it already goes into syslog # since I'm running this from systemctl it already goes into syslog
@ -26,11 +24,11 @@ if __name__ == '__main__':
# this is ok to be read-only # this is ok to be read-only
sdb = shared.SearchDB() sdb = shared.SearchDB()
@app.route("/oauth1", methods=["GET"]) @app.route("/oauth1", methods=["GET"])
async def oauth1(request): async def oauth1(request):
token = request.args.get('oauth_token') token = request.args.get('oauth_token')
verifier = request.args.get('oauth_verifier') verifier = request.args.get('oauth_verifier')
logging.info("incoming oauth request: token was %s ; verifier was %s", token, verifier)
tokendb = shared.TokenDB() tokendb = shared.TokenDB()
tokendb.update_token( tokendb.update_token(
token, token,
@ -38,7 +36,6 @@ if __name__ == '__main__':
) )
return sanic.response.text("OK", status=200) return sanic.response.text("OK", status=200)
@app.route("/search", methods=["GET"]) @app.route("/search", methods=["GET"])
async def search(request): async def search(request):
query = request.args.get('s') query = request.args.get('s')
@ -46,12 +43,10 @@ if __name__ == '__main__':
response = sanic.response.html(r, status=200) response = sanic.response.html(r, status=200)
return response return response
@app.route("/micropub", methods=["POST", "GET"]) @app.route("/micropub", methods=["POST", "GET"])
async def micropub(request): async def micropub(request):
return sanic.response.text("Not Implemented", status=501) return sanic.response.text("Not Implemented", status=501)
@app.route("/webmention", methods=["POST"]) @app.route("/webmention", methods=["POST"])
async def webmention(request): async def webmention(request):
source = request.form.get('source') source = request.form.get('source')
@ -89,5 +84,4 @@ if __name__ == '__main__':
response = sanic.response.text("Accepted", status=202) response = sanic.response.text("Accepted", status=202)
return response return response
app.run(host="127.0.0.1", port=8008, log_config=None) app.run(host="127.0.0.1", port=8008, log_config=None)