hi I created a simple website to calculate the square of the number. below is the code calculate.html homepage.html python now I want to display input number in URL path. e.g. http://127.0.0.1:3000/square/10 so I’ve tried this but it didn’t work. What could I do? Answer You could get variables dir…
Tag: flask
Python, Mqtt : can publish but can’t receive message on docker
I’m running two dockers : one for the mqtt server using mosquitto the other using flask_mqtt the flask container is receiving the CONNACK and is sending the subscribe to the broker but never get any SUBACK however it manages to publish hello word to /home/mytopic (mqtt-explorer proof) this is quite stra…
Can a website’s controlling Python code be viewed?
I am trying to place a simple Flask app within a Docker container to be hosted on Firebase as per David East’s article on https://medium.com/firebase-developers/hosting-flask-servers-on-firebase-from-scratch-c97cfb204579 Within the app, I have used Flask email to send emails automatically. Is it safe to…
Flask-SQLAlchemy db.create_all() raises RuntimeError working outside of application context
I recently updated Flask-SQLAlchemy, and now db.create_all is raising RuntimeError: working outside of application context. How do I call create_all? This raises the following error: Answer As of Flask-SQLAlchemy 3.0, all access to db.engine (and db.session) requires an active Flask application context. db.cr…
How to run server in development mode with flask?
I am learning to use flask and I want to run the server for an application in development mode, for this I do the following: When I run I get the following in the terminal: enter image description here Environment:development does not appear to me as I understand it should appear. In fact, before doing this I…
Flask error: Method Not Allowed The method is not allowed for the requested URL
Everytime I register a new person in my website, it appears the “Method Not Allowed The method is not allowed for the requested URL.” Page. Can anyone help me? /// Toda vez que eu cadastro uma nova pessoa no meu site, aparece a página “Method Not Allowed. The method is not allowed for the re…
How to add a function to app context in flask
I am trying to use flask blueprints to organize the flask projects I build. And I found out a that context can be used to export variables from main.py to blueprints. main.py(or _init_.py) my_data can be retrieved from a blueprint using current_app bp1.py Now I created a function rand_string in main.py and wa…
Im managed to display values of a table in html with flask and python but i dont understand the logic behind my solution
this part of code im using to Display the entries in the database on index.html birthday database and this is the html code i use to display the name, the month , and day can someone explain if i have assign and the variable name = people whats the logic behind this loop ? Answer I recommend you to learn
How to collect WTForms data through loop without explicitly stating the name of each field?
I am following CoreyMSchafer’s Flask-blog tutorial. Here, I can create, update and delete posts using WTForms and SQLAlchemy. However, to do that, I have to explicitly mention the name of the form fields. For example, to update a post (assuming a post only has title and content): where the model is and …
Why does my flask route show 404, after trying to link it into my starting page
enter image description here[ How my search route appears This the code used in my app.py. I have tried {href=”./search.html”} but there is no difference. Edit How my project folder looks like Edit 2: My mistake in the routing Answer EDIT to link your routes from within your HTML pages, you can us…