Compare commits
1 commit
| Author | SHA1 | Date | |
|---|---|---|---|
| beb4f96d81 |
3 changed files with 71 additions and 4 deletions
20
app.py
20
app.py
|
|
@ -524,9 +524,9 @@ def download_database_view(request):
|
||||||
download_filename = sanitize_filename_for_http_header(f"user_{user.id}.db")
|
download_filename = sanitize_filename_for_http_header(f"user_{user.id}.db")
|
||||||
|
|
||||||
response = Response(body=data, content_type="application/octet-stream")
|
response = Response(body=data, content_type="application/octet-stream")
|
||||||
response.headers[
|
response.headers["Content-Disposition"] = (
|
||||||
"Content-Disposition"
|
f'attachment; filename="{download_filename}"'
|
||||||
] = f'attachment; filename="{download_filename}"'
|
)
|
||||||
return response
|
return response
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1005,7 +1005,19 @@ def main(global_config=None, **settings):
|
||||||
config.add_jinja2_renderer(".j2")
|
config.add_jinja2_renderer(".j2")
|
||||||
config.add_jinja2_search_path("templates", name=".j2")
|
config.add_jinja2_search_path("templates", name=".j2")
|
||||||
|
|
||||||
# The Jinja2 filters are added via the event subscriber above
|
# Add settings for pyramid_openapi3
|
||||||
|
config.add_settings(
|
||||||
|
{
|
||||||
|
"pyramid_openapi3.spec": os.path.join(APP_DIR, "openapi.yaml"),
|
||||||
|
"pyramid_openapi3.enable_request_validation": True,
|
||||||
|
"pyramid_openapi3.enable_response_validation": False,
|
||||||
|
"pyramid_openapi3.route": "/openapi.yaml",
|
||||||
|
"pyramid_openapi3.ui_route": "/docs/",
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
# Include pyramid_openapi3
|
||||||
|
config.include("pyramid_openapi3")
|
||||||
|
|
||||||
# Set up SQLAlchemy
|
# Set up SQLAlchemy
|
||||||
engine = create_engine(
|
engine = create_engine(
|
||||||
|
|
|
||||||
53
openapi.yaml
Normal file
53
openapi.yaml
Normal file
|
|
@ -0,0 +1,53 @@
|
||||||
|
openapi: 3.0.0
|
||||||
|
info:
|
||||||
|
title: PyraFiles API
|
||||||
|
version: '1.0'
|
||||||
|
paths:
|
||||||
|
/auth/login:
|
||||||
|
post:
|
||||||
|
summary: User login
|
||||||
|
requestBody:
|
||||||
|
required: true
|
||||||
|
content:
|
||||||
|
application/x-www-form-urlencoded:
|
||||||
|
schema:
|
||||||
|
type: object
|
||||||
|
properties:
|
||||||
|
email:
|
||||||
|
type: string
|
||||||
|
responses:
|
||||||
|
'302':
|
||||||
|
description: Redirect to verification page
|
||||||
|
/auth/verify:
|
||||||
|
post:
|
||||||
|
summary: Verify user code
|
||||||
|
requestBody:
|
||||||
|
required: true
|
||||||
|
content:
|
||||||
|
application/x-www-form-urlencoded:
|
||||||
|
schema:
|
||||||
|
type: object
|
||||||
|
properties:
|
||||||
|
code:
|
||||||
|
type: string
|
||||||
|
responses:
|
||||||
|
'302':
|
||||||
|
description: Redirect to home page
|
||||||
|
/media/upload:
|
||||||
|
post:
|
||||||
|
summary: Upload media file
|
||||||
|
requestBody:
|
||||||
|
required: true
|
||||||
|
content:
|
||||||
|
multipart/form-data:
|
||||||
|
schema:
|
||||||
|
type: object
|
||||||
|
properties:
|
||||||
|
media_file:
|
||||||
|
type: string
|
||||||
|
format: binary
|
||||||
|
title:
|
||||||
|
type: string
|
||||||
|
responses:
|
||||||
|
'302':
|
||||||
|
description: Redirect to media details page
|
||||||
|
|
@ -11,3 +11,5 @@ zope.sqlalchemy
|
||||||
bcrypt
|
bcrypt
|
||||||
sqlalchemy
|
sqlalchemy
|
||||||
werkzeug
|
werkzeug
|
||||||
|
|
||||||
|
pyramid_openapi3
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue