Compare commits

...
Sign in to create a new pull request.

1 commit

Author SHA1 Message Date
beb4f96d81 halp, why doesn't this work? getting http 404
modified:   app.py
	new file:   openapi.yaml
	modified:   requirements.txt
2025-01-07 08:03:27 -05:00
3 changed files with 71 additions and 4 deletions

20
app.py
View file

@ -524,9 +524,9 @@ def download_database_view(request):
download_filename = sanitize_filename_for_http_header(f"user_{user.id}.db")
response = Response(body=data, content_type="application/octet-stream")
response.headers[
"Content-Disposition"
] = f'attachment; filename="{download_filename}"'
response.headers["Content-Disposition"] = (
f'attachment; filename="{download_filename}"'
)
return response
@ -1005,7 +1005,19 @@ def main(global_config=None, **settings):
config.add_jinja2_renderer(".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
engine = create_engine(

53
openapi.yaml Normal file
View 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

View file

@ -11,3 +11,5 @@ zope.sqlalchemy
bcrypt
sqlalchemy
werkzeug
pyramid_openapi3