changed url import api call to post url

This commit is contained in:
vabene1111
2020-08-09 20:13:05 +02:00
parent 782d276724
commit a8b1ee9765
3 changed files with 5 additions and 3 deletions

View File

@ -295,7 +295,7 @@
this.recipe_data = undefined this.recipe_data = undefined
this.error = undefined this.error = undefined
this.loading = true this.loading = true
this.$http.get("{% url 'api_recipe_from_url' 12345 %}".replace(/12345/, this.remote_url)).then((response) => { this.$http.post("{% url 'api_recipe_from_url' %}", {'url' : this.remote_url}, {emulateJSON: true}).then((response) => {
this.recipe_data = response.data; this.recipe_data = response.data;
this.loading = false this.loading = false
}).catch((err) => { }).catch((err) => {

View File

@ -69,7 +69,7 @@ urlpatterns = [
path('api/sync_all/', api.sync_all, name='api_sync'), path('api/sync_all/', api.sync_all, name='api_sync'),
path('api/log_cooking/<int:recipe_id>/', api.log_cooking, name='api_log_cooking'), path('api/log_cooking/<int:recipe_id>/', api.log_cooking, name='api_log_cooking'),
path('api/plan-ical/<slug:html_week>/', api.get_plan_ical, name='api_get_plan_ical'), path('api/plan-ical/<slug:html_week>/', api.get_plan_ical, name='api_get_plan_ical'),
path('api/recipe-from-url/<path:url>/', api.recipe_from_url, name='api_recipe_from_url'), path('api/recipe-from-url/', api.recipe_from_url, name='api_recipe_from_url'),
path('api/backup/', api.get_backup, name='api_backup'), path('api/backup/', api.get_backup, name='api_backup'),
path('dal/keyword/', dal.KeywordAutocomplete.as_view(), name='dal_keyword'), path('dal/keyword/', dal.KeywordAutocomplete.as_view(), name='dal_keyword'),

View File

@ -346,7 +346,9 @@ def get_plan_ical(request, html_week):
@group_required('user') @group_required('user')
def recipe_from_url(request, url): def recipe_from_url(request):
url = request.POST['url']
headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.106 Safari/537.36'} headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.106 Safari/537.36'}
try: try:
response = requests.get(url, headers=headers) response = requests.get(url, headers=headers)