mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-07-25 12:08:40 +02:00
Implement API
This commit is contained in:
parent
67f9de03d4
commit
e52954f984
2 changed files with 35 additions and 0 deletions
32
src/api/report_views.py
Normal file
32
src/api/report_views.py
Normal file
|
@ -0,0 +1,32 @@
|
|||
"""Internal API views"""
|
||||
from django.apps import apps
|
||||
from django.views.decorators.http import require_http_methods
|
||||
from django.http import FileResponse, JsonResponse
|
||||
|
||||
import requests
|
||||
|
||||
|
||||
from registrar.utility import csv_export
|
||||
from login_required import login_not_required
|
||||
|
||||
@require_http_methods(["GET"])
|
||||
@login_not_required
|
||||
def get_current_full(request):
|
||||
# Generate the CSV file
|
||||
with open("current-full.csv", "w") as file:
|
||||
csv_export.export_data_full_to_csv(file)
|
||||
|
||||
# Serve the CSV file
|
||||
response = FileResponse(open('current-full.csv', 'rb'))
|
||||
return response
|
||||
|
||||
@require_http_methods(["GET"])
|
||||
@login_not_required
|
||||
def get_current_federal(request):
|
||||
# Generate the CSV file
|
||||
with open("current-federal.csv", "w") as file:
|
||||
csv_export.export_data_federal_to_csv(file)
|
||||
|
||||
# Serve the CSV file
|
||||
response = FileResponse(open('current-federal.csv', 'rb'))
|
||||
return response
|
Loading…
Add table
Add a link
Reference in a new issue