python - Q: Django - how to return data from other function on views.py -
python - Q: Django - how to return data from other function on views.py -
i'm kind of working on string operation, here want do - created functions gettext(request) getting text *.txt files, code
def gettext(request): if request.method == 'post': form = uploadfileform(request.post, request.files) if form.is_valid(): f = request.files['file'] chunk in f.chunks(): text = chunk homecoming render(request, 'ecs/index.html', {'text': text, 'form': form}) else: form = uploadfileform() homecoming render_to_response('ecs/index.html', {'form': form})
and want info stored on text variable functions, called preprocessing
def preprocessing(text): pp = preprocess() wordtokenize = pp.tokenizing(text) homecoming wordtokenize
how can utilize preprocessing(text) method handle info text variable on gettext method. tried tricks, still no progress.
import preprocessing function wherever have file has gettext in it, , this:
def gettext(request): if request.method == 'post': form = uploadfileform(request.post, request.files) if form.is_valid(): f = request.files['file'] chunk in f.chunks(): text = chunk text = preprocessing(text) homecoming render(request, 'ecs/index.html', {'text': text, 'form': form}) else: form = uploadfileform() homecoming render_to_response('ecs/index.html', {'form': form})
python django
Comments
Post a Comment