Skip to main content

A Flask extension for embedding python code directly in HTML templates.

Project description

Flask-Embed Project 🚀🐍

Flask-Embed Logo

Flask-Embed is a Flask extension that allows you to run Python code directly from your HTML templates. This can be incredibly useful for convience of running python from the HTML templates as a convience. 🎉

Installation 📦

You can install Flask-Embed using pip:

pip install Flask-Embed

Usage Example 💻

Here's a simple example of how to use Flask with the Flask-Embed library:

from flask import Flask
from flask_embed import Embed

app = Flask(__name__)
embed = Embed()

@app.route('/')
def hello_world():
    return embed.render_template('index.html', embed=embed)

if __name__ == '__main__':
    app.run(debug=True)

How It Works 🛠️

Flask-Embed allows you to embed Python code within your HTML templates using special tags. The embedded Python code is executed on the server side, and the output is rendered in the HTML.

Example HTML Template 📄

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Reactive Flask</title>
</head>
<body>
    <h1>Python Embed Test</h1>
    <p>Python code:</p>
    <FlaskOutput></FlaskOutput>
</body>
</html>

Embedded Python Code 🐍

<Flask>
import urllib.request
import json

with urllib.request.urlopen("https://jsonplaceholder.typicode.com/posts") as response:
    data = response.read()
    posts = json.loads(data)
    output = posts[:5]
</Flask>

The above code fetches data from an API and displays the first five posts in the HTML template. 🌐

Conclusion 🎯

Flask-Embed makes it easy to integrate Python code into your HTML templates, providing a seamless way to create dynamic web applications. Give it a try and see how it can simplify your Flask projects! 🚀

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

flask_embed-0.0.1.tar.gz (4.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

Flask_Embed-0.0.1-py3-none-any.whl (5.1 kB view details)

Uploaded Python 3

File details

Details for the file flask_embed-0.0.1.tar.gz.

File metadata

  • Download URL: flask_embed-0.0.1.tar.gz
  • Upload date:
  • Size: 4.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.8

File hashes

Hashes for flask_embed-0.0.1.tar.gz
Algorithm Hash digest
SHA256 21d4ba60631a940c643b2642d46bcb24bf6d6d9597ffd4dadae0e95c5dc0fe51
MD5 b2baffe960f61aa732da5ff2efb37864
BLAKE2b-256 cb093691055fe84e0ba06c681b69b7a5be3ca72fbe2e488284e3d7577d4b6c35

See more details on using hashes here.

File details

Details for the file Flask_Embed-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: Flask_Embed-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 5.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.8

File hashes

Hashes for Flask_Embed-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 5bd38435b4bb85b18fb3d6712d6335059665291d526ab4480e7d31f01a4ed49b
MD5 b7769ce90315845f869c7cfa39409abb
BLAKE2b-256 967122705539926fefb7bbc2f2955deb47de6a18293087aefd5b867706b278b5

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page