semvec/pypi-packages huggingface dataset:
flask-transcrypt 0.1.1
Flask extension to integrate Transcrypt

# FlaskTranscrypt

FlaskTranscrypt is a Flask extension that integrates Transcrypt, a Python to JavaScript compiler. It automatically compiles Python files in a specified source directory to JavaScript before each request.

## Features

- Automatic compilation of Python files to JavaScript using Transcrypt.
- Easy integration with Flask applications.
- Configurable source and target directories.

## Installation

To install FlaskTranscrypt, you can use pip:

```bash
pip install flask-transcrypt
or 
pip3 install flask-transcrypt
```

## Usage

### Initialization

First, import and initialize the `FlaskTranscrypt` extension in your Flask application:

```python
from flask import Flask
from flask_transcrypt import FlaskTranscrypt

app = Flask(__name__)
transcrypt = FlaskTranscrypt(app)

if __name__ == "__main__":
    app.run()
```

### Configuration

You can configure the source and target directories for the Transcrypt compilation in your Flask application's configuration. If these configurations are not defined, the extension will use the default values:

```python
app.config["TRANSCRYPT_SOURCE_DIR"] = "/path/to/source/directory"
app.config["TRANSCRYPT_TARGET_DIR"] = "/path/to/target/directory"
```

By default, the source directory is set to the Flask application's static folder, and the target directory is set to `__target__` within the static folder.

### Template Integration

In your Flask template, include the compiled JavaScript file using the following script tag:

```html
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Flask Transcrypt Example</title>
</head>
<body>
    <!-- Your HTML content goes here -->

    <!-- Include the compiled JavaScript file -->
    <script type="module" src="{{ url_for('static', filename='__target__/name_for_file.js') }}"></script>
</body>
</html>
```

Replace `name_for_file.js` with the actual name of your compiled JavaScript file.

## Example

Here is a complete example of how to use FlaskTranscrypt in a Flask application:

```python
from flask import Flask
from flask_transcrypt import FlaskTranscrypt

app = Flask(__name__)
transcrypt = FlaskTranscrypt(app)

if __name__ == "__main__":
    app.run()
```

In your template (e.g., `index.html`):

```html
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Flask Transcrypt Example</title>
</head>
<body>
    <!-- Your HTML content goes here -->

    <!-- Include the compiled JavaScript file -->
    <script type="module" src="{{ url_for('static', filename='__target__/name_for_file.js') }}"></script>
</body>
</html>
```

## License

This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.

## Contributing

Contributions are welcome! Please open an issue or submit a pull request.

## Acknowledgments

- [Transcrypt](https://www.transcrypt.org/) for the Python to JavaScript compiler.
- [Flask](https://flask.palletsprojects.com/) for the web framework.
hstrader 1.1.0
HsTrader SDK for Python
Requires Python: <4.0,>=3.7

# HsTrader SDK for Python

![PyPI - Version](https://img.shields.io/pypi/v/hstrader)
![PyPI - Python Version](https://img.shields.io/pypi/pyversions/hstrader)
[![Documentation](https://img.shields.io/badge/docs-latest-blue)](https://staging.hstrader.com/trader/docs/)
[![License: Apache-2.0](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)


hstrader-sdk-py is the [HsTrader](https://hstrader.com) SDK for Python.

The HsTrader SDK requires a minimum version of Python 3.7.

## Installation

```bash
pip install hstrader
```

## Documentation

You can find the latest documentation at the official [HsTrader API documentation](https://demo.hstrader.com/trader/docs)

## Getting Started

### Http Example

```python
from hstrader import HsTrader


# Its recommended to use environment variables to store your credentials
CLIENT_ID = "<YOUR_CLIENT_ID>"
CLIENT_SECRET = "<YOUR_CLIENT_SECRET>"
URL = "<YOUR_BROKER_URL>"


# Create a new instance of HSTrader
client = HsTrader(CLIENT_ID, CLIENT_SECRET, URL)

try:

    # Get the EURUSD symbol
    eurusd = client.get_symbol("EURUSD")
    print(
        f"Symbol ID: {eurusd.id}, Name: {eurusd.symbol}, Last Bid: {eurusd.last_bid}, Last Ask: {eurusd.last_ask}"
    )

except Exception as e:
    print(e)


```

### Websocket Example

```python
from hstrader import HsTrader
from hstrader.models import Event, Tick


# Its recommended to use environment variables to store your credentials
CLIENT_ID = "<YOUR_CLIENT_ID>"
CLIENT_SECRET = "<YOUR_CLIENT_SECRET>"
URL = "<YOUR_BROKER_URL>"


# Create a new instance of HSTrader
client = HsTrader(CLIENT_ID, CLIENT_SECRET, URL)


# Create a callback function to handle market updates
@client.subscribe(Event.MARKET) # alternatively, you can use @client.subscribe("market")
def on_market(tick: Tick):  # this function will be called whenever a new market update is received
    print(
        f"Received tick for symbol {tick.symbol_id}: bid = {tick.bid} ask = {tick.ask}"
    )


# Start listening to real-time data
client.start()


```

For more examples, please refer to the [examples](/examples/) directory.
## Contributing

Contributions are welcome.<br/>
If you've found a bug within this project, please open an issue to discuss what you would like to change.<br/>
If it's an issue with the API, please open a topic at [Contact Us](https://hstrader.com/contact-us/).