GithubHelp home page GithubHelp logo

mrf345 / flask_googletrans Goto Github PK

View Code? Open in Web Editor NEW
12.0 12.0 4.0 25 KB

Googletrans google translation flask extension

License: MIT License

Python 100.00%
extension flask flask-googletrans googletrans translation

flask_googletrans's People

Contributors

mrf345 avatar skywolf123 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

flask_googletrans's Issues

Pytest failed

When I run pytest

pytest

There are three test failed:

=================================================== short test summary info =================================================== 
FAILED test_fg.py::test_translate_multi_new_mod - AttributeError: 'NoneType' object has no attribute 'group'
FAILED test_fg.py::test_translator_false_input - FileNotFoundError: [WinError 2] The system cannot find the file specified: '...
FAILED test_fg.py::test_translate_failsafe - AssertionError: assert 'falsely modified' == 'something to say'

I am wondering what caused this. I am currently trying to see if there is any flaky tests in test design so I need to get all tests pass at first.

error "httpcore._exceptions.ConnectTimeout: _ssl.c:1091: The handshake operation timed out"

First, I use pip install Flask-Googletrans and successfully installed the extension.
My app.py is as bellow:

`from flask import Flask, render_template
from flask_googletrans import translator

app = Flask(name)
ts = translator(app)

@app.route('/')
def hello_world():
title = "hello"
title = ts.translate(text=title, src='en', dest=['ja'])
return render_template("index.html", title=title)

if name == 'main':
app.run()
the jinja template file is as bellow:

<title>Title</title>

{{ title }}

`

When running on http://127.0.0.1:5000, I got errors as bellow:
[2022-09-12 15:55:46,765] ERROR in app: Exception on / [GET] Traceback (most recent call last): File "C:\Users\X1 Carbon\AppData\Local\Programs\Python\Python38-32\lib\site-packages\flask\app.py", line 2525, in wsgi_app response = self.full_dispatch_request() File "C:\Users\X1 Carbon\AppData\Local\Programs\Python\Python38-32\lib\site-packages\flask\app.py", line 1822, in full_dispatch_request rv = self.handle_user_exception(e) File "C:\Users\X1 Carbon\AppData\Local\Programs\Python\Python38-32\lib\site-packages\flask\app.py", line 1820, in full_dispatch_request rv = self.dispatch_request() File "C:\Users\X1 Carbon\AppData\Local\Programs\Python\Python38-32\lib\site-packages\flask\app.py", line 1796, in dispatch_request return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args) File "D:\Python\workplace\testtranslate\app.py", line 10, in hello_world title = ts.translate(text=title, src='en', dest=['ja']) File "C:\Users\X1 Carbon\AppData\Local\Programs\Python\Python38-32\lib\site-packages\flask_googletrans\__init__.py", line 171, in translate translation = translator.translate( File "C:\Users\X1 Carbon\AppData\Local\Programs\Python\Python38-32\lib\site-packages\googletrans\client.py", line 182, in translate data = self._translate(text, dest, src, kwargs) File "C:\Users\X1 Carbon\AppData\Local\Programs\Python\Python38-32\lib\site-packages\googletrans\client.py", line 78, in _translate token = self.token_acquirer.do(text) File "C:\Users\X1 Carbon\AppData\Local\Programs\Python\Python38-32\lib\site-packages\googletrans\gtoken.py", line 194, in do self._update() File "C:\Users\X1 Carbon\AppData\Local\Programs\Python\Python38-32\lib\site-packages\googletrans\gtoken.py", line 54, in _update r = self.client.get(self.host) File "C:\Users\X1 Carbon\AppData\Local\Programs\Python\Python38-32\lib\site-packages\httpx\_client.py", line 755, in get return self.request( File "C:\Users\X1 Carbon\AppData\Local\Programs\Python\Python38-32\lib\site-packages\httpx\_client.py", line 600, in request return self.send( File "C:\Users\X1 Carbon\AppData\Local\Programs\Python\Python38-32\lib\site-packages\httpx\_client.py", line 620, in send response = self.send_handling_redirects( File "C:\Users\X1 Carbon\AppData\Local\Programs\Python\Python38-32\lib\site-packages\httpx\_client.py", line 647, in send_handling_redirects response = self.send_handling_auth( File "C:\Users\X1 Carbon\AppData\Local\Programs\Python\Python38-32\lib\site-packages\httpx\_client.py", line 684, in send_handling_auth response = self.send_single_request(request, timeout) File "C:\Users\X1 Carbon\AppData\Local\Programs\Python\Python38-32\lib\site-packages\httpx\_client.py", line 714, in send_single_request ) = transport.request( File "C:\Users\X1 Carbon\AppData\Local\Programs\Python\Python38-32\lib\site-packages\httpcore\_sync\http_proxy.py", line 110, in request return self._tunnel_request( File "C:\Users\X1 Carbon\AppData\Local\Programs\Python\Python38-32\lib\site-packages\httpcore\_sync\http_proxy.py", line 191, in _tunnel_request proxy_response = proxy_connection.request( File "C:\Users\X1 Carbon\AppData\Local\Programs\Python\Python38-32\lib\site-packages\httpcore\_sync\connection.py", line 65, in request self.socket = self._open_socket(timeout) File "C:\Users\X1 Carbon\AppData\Local\Programs\Python\Python38-32\lib\site-packages\httpcore\_sync\connection.py", line 85, in _open_socket return self.backend.open_tcp_stream( File "C:\Users\X1 Carbon\AppData\Local\Programs\Python\Python38-32\lib\site-packages\httpcore\_backends\sync.py", line 139, in open_tcp_stream return SyncSocketStream(sock=sock) File "C:\Users\X1 Carbon\AppData\Local\Programs\Python\Python38-32\lib\contextlib.py", line 131, in __exit__ self.gen.throw(type, value, traceback) File "C:\Users\X1 Carbon\AppData\Local\Programs\Python\Python38-32\lib\site-packages\httpcore\_exceptions.py", line 12, in map_exceptions raise to_exc(exc) from None httpcore._exceptions.ConnectTimeout: _ssl.c:1091: The handshake operation timed out
What should I do to deal with the error? Thank you for your time.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.