Win a copy of Terraform in Action this week in the Cloud forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

How to save api output as excel in python flask

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i am trying to save the api json output as excel format in python using xlsxwriter but unable to save it

this is what i tried





This is the error i am getting "TypeError: Object of type UUID is not JSON serializable"

kindly guide.
 
Ranch Hand
Posts: 82
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

What you should realize is that developing a website with Flask is essentially writing regular Python code with a little bit of ‘website-specific code. Flask is very lightweight; it gives you the essentials, but that’s it — apart from plugins.

To start, you don’t need to know much more than the following:

You create a Flask instance
from flask import Flask

app = Flask(__name__)  # don't worry about the __name__ bit for now
Each page is handled by a function, whose route is registered by a decorator
@app.route("/")
def index():
   pass
The app. route bit simply registers the function below to a specific path. It’s an alternative to app.add_url_rule('/', 'index', index). It’s just telling the app to refer to the index function whenever a user requests ‘/’.

Each of these functions can render a website using the data that you got using ‘regular Python’
import datetime  
from flask import render_template  
def index():
   current_dt = datetime.datetime.now()
   render_template("index.html",
current_dt=current_dt)
You need a templates/index.html file which is written using Jinja2. This is regular HTML mixed with a specific syntax for logic and to use the data that ‘was sent to’ the template using the render_template function.

<html>
<head>
<title>My website
</head>
<body>
{{ current_dt.strftime("%H:%M" }}  # using a custom filter would be better, but is out of the scope of this answer
</body>
</html>  
You run your development server

app.run()
And that’s it. Your first Flask website shows the current time. Everything else just expands on this basis.


I hope this will help you
reply
    Bookmark Topic Watch Topic
  • New Topic