Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Starting this App with Flask is slow, it takes a few seconds to load #1138

Unanswered
Alan3344 asked this question in Problem
Discussion options

Here is the simple test code

  • This phenomenon did not occur when I used Fastapi
  • I don't know about other frameworks without testing
# index_flask.py
from reactpy import component, html
@component
def Index():
 return html.div(
 html.h1('Test Flask App'),
 html.h2('Hello World'),
 )
# main-flask.py
from index_flask import Index
from reactpy.backend.flask import configure, Flask
app = Flask(__name__)
app.config['debug'] = True
configure(app, Index)
print(app.url_map)

default at http://127.0.0.1:8000

# startup it
gunicorn main-flask:app --reload
  • Running this for the first time will output
(.venv) ➜ recatpy_ gunicorn main-flask:app --reload
[2023年08月29日 15:46:36 +0700] [81626] [INFO] Starting gunicorn 21.2.0
[2023年08月29日 15:46:36 +0700] [81626] [INFO] Listening at: http://127.0.0.1:8000 (81626)
[2023年08月29日 15:46:36 +0700] [81626] [INFO] Using worker: sync
[2023年08月29日 15:46:36 +0700] [81627] [INFO] Booting worker with pid: 81627
Map([<Rule '/_reactpy/stream' (OPTIONS, HEAD, GET) -> reactpy_api_4392762960.without_path>,
 <Rule '/' (OPTIONS, HEAD, GET) -> reactpy_spa_4392762960.send_client_dir>,
 <Rule '/_reactpy/modules/<path>' (OPTIONS, HEAD, GET) -> reactpy_api_4392762960.send_modules_dir>,
 <Rule '/_reactpy/stream/<path>' (OPTIONS, HEAD, GET) -> reactpy_api_4392762960.with_path>,
 <Rule '/_reactpy/assets/<path>' (OPTIONS, HEAD, GET) -> reactpy_api_4392762960.send_assets_dir>,
 <Rule '/static/<filename>' (OPTIONS, HEAD, GET) -> static>,
 <Rule '/<_>' (OPTIONS, HEAD, GET) -> reactpy_spa_4392762960.send_client_dir>])
(.venv) ➜ recatpy_ pip list freeze
Package Version
------------------ ---------
aiohttp 3.8.5
aiosignal 1.3.1
annotated-types 0.5.0
anyio 3.7.1
asgiref 3.7.2
async-timeout 4.0.3
attrs 23.1.0
blinker 1.6.2
certifi 2023年7月22日
charset-normalizer 3.2.0
click 8.1.7
colorlog 6.7.0
fastapi 0.103.0
fastjsonschema 2.18.0
Flask 2.3.3
Flask-Cors 4.0.0
flask-sock 0.6.0
frozenlist 1.4.0
h11 0.14.0
httpcore 0.17.3
httptools 0.6.0
httpx 0.24.1
idna 3.4
itsdangerous 2.1.2
Jinja2 3.1.2
jsonpatch 1.33
jsonpointer 2.4
lxml 4.9.3
markdown-it-py 3.0.0
MarkupSafe 2.1.3
mdurl 0.1.2
multidict 6.0.4
mypy-extensions 1.0.0
pip 23.2.1
pydantic 2.3.0
pydantic_core 2.6.3
Pygments 2.16.1
python-dotenv 1.0.0
PyYAML 6.0.1
reactpy 1.0.2
reactpy-router 0.1.0
requests 2.31.0
rich 13.5.2
setuptools 68.1.2
simple-websocket 0.10.1
sniffio 1.3.0
starlette 0.27.0
typing_extensions 4.7.1
urllib3 2.0.4
uvicorn 0.23.2
uvloop 0.17.0
watchfiles 0.20.0
websockets 11.0.3
Werkzeug 2.3.7
wsproto 1.2.0
yarl 1.9.2
You must be logged in to vote

Replies: 1 comment

Comment options

I recorded a video to verify this

2566年08月29日.16.18.30.mov
You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
1 participant

AltStyle によって変換されたページ (->オリジナル) /