浏览代码

effettuate alcune modifiche nel controllo files

mauro 1 月之前
父节点
当前提交
cabb93c17e
共有 2 个文件被更改,包括 33 次插入8 次删除
  1. 9 0
      .gitignore
  2. 24 8
      frontpage/views.py

+ 9 - 0
.gitignore

@@ -0,0 +1,9 @@
+*.pyc
+*.log
+*.bak
+*~
+db/db.sqlite3
+*.saved
+*.saved.cvtd
+gd/settings.py
+static/upload/

+ 24 - 8
frontpage/views.py

@@ -76,6 +76,11 @@ def esegue_conversione(inputfile):
       r.close()
       risultato[k] = {'file':"{}/out/{}.pdf".format(MEDIA_ROOT,k),'pagine':listapagine[k]}
 
+      '''
+      fino a qui e' tutto chiaro.
+      il file elaborato viene salvato in out denetro la cartella MEDIA_ROOT
+      '''
+
        
   else: risultato['errore']=[]
 
@@ -87,14 +92,21 @@ def esegue_conversione(inputfile):
 
 @csrf_exempt
 def frontpage(request):
+  print(__name__)
   listaccepted = list()
   listaccepted.append('195.110.154.210')
   listaccepted.append('195.110.154.213')
+  listaccepted.append('127.0.0.1')
+
 
-  print('x_real_ip',request.META['HTTP_X_REAL_IP'])
-  print('http_host',request.META['HTTP_HOST'])
+  print(request.META)
+  if 'x_real_ip'.upper() in request.META:
+    print('x_real_ip',request.META['HTTP_X_REAL_IP'])
+  if 'http_host'.upper() in request.META:
+    print('http_host',request.META['HTTP_HOST'])
+  if 'remote_address'.upper() in request.META:
+    print('remote_addrews',request.META['REMOTE_ADDR'])
 
-  '''
   auth = False
 
   if 'HTTP_X_REAL_IP' in request.META:
@@ -102,14 +114,18 @@ def frontpage(request):
     if request.META['HTTP_X_REAL_IP'] in listaccepted:
       print('found presente X_REAL_IP',request.META['HTTP_X_REAL_IP'])
       auth = True
-  else:
-      if 'HTTP_HOST' in request.META:
-        if request.META['HTTP_HOST'] in listaccepted:
-          auth = True
+  if 'HTTP_HOST' in request.META:
+    if request.META['HTTP_HOST'] in listaccepted:
+      print('found presente HTTP_HOST',request.META['HTTP_HOST'])
+      auth = True
+  if 'REMOTE_ADDR' in request.META:
+    if request.META['REMOTE_ADDR'] in listaccepted:
+      print('found presente REMOTE_ADDR',request.META['REMOTE_ADDR'])
+      auth = True
+
 
   if not auth:
     return HttpResponse("Accesso Non Autorizzato", status=503, headers={})
-  '''
 
   data = {}
   print('request.method',request.method)