-4

I am having a 1D numpy array in Python that I want to render on my webpage using the flask framework. How to do that?

As of now I am trying to convert it into list and then display that. Is there any more direct way for the same. The array length is variable that depends on a computation.

  • Does [this question](https://stackoverflow.com/questions/1987694/print-the-full-numpy-array) solve your problem? You question seems to simply be "How do I convert a numpy array to a string" – Eric Apr 09 '16 at 05:25

1 Answers1

0

You can simply convert the numpy array to a string as suggested in the comments. As a visual example try:

>>> import numpy as np
>>> x = np.ones(10, dtype=int)
>>> str(x)
'[1 1 1 1 1 1 1 1 1 1]'

In flask you can simply return that value in a response since it is nothing more complex than a string.

MS-DDOS
  • 558
  • 5
  • 14