Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I'm new to Flask but have experience with PHP. I know there are session variables and global variables just as in PHP, but what do the contexts actually mean? I read the documentation but could not understand whet it was saying.
What are the application and request contexts, and what the is app.app_context()?
app.app_context loads the application and any extentions you have loaded.
A request context is loaded when you are dealing with a request.
A good example.
If you have a background cron that does some database work, you'll need to make use of app_context to get access to the models.
You'll be a in request context pretty much whenever you're handling a view.
Related
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I want to write a custom error log class, which would show me the errors returned by the code. I don't use google app engine, I use python tornado framework.
So can anyone guide me with steps to follow.
I have actually got the steps to follow to create the custom logger from the below link:
Python: custom logging across all modules
But how do i actually store the logs in db and pull it and post it on my front end.
import logging
logging.basicConfig(...)
try:
do.something()
except Exception:
logging.exception("aiii!")
Eventually you'll want to move off basicConfig.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I am learning Flask and I want to practice by making simple web app.
I want to make a chat web app that allows sending messages between two or more web browsers in Flask but I am not sure where to start or go about building this application. This question is pretty broad but what I want to know is how to structure this application. What are the pieces I need to build this application.
very broad question, but I'd recommend starting here with web sockets http://blog.miguelgrinberg.com/post/easy-websockets-with-flask-and-gevent . Then you can have two member subscribe to a channel and make messages to each other.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I have used scarpy to scrap some text from a website. But I am not quite sure how to store them in sqlite?Can anyone help me with the code?
while you can find some examples that are using blocking operations to interact with the database it is worth noting that scrapy is built on top of twisted library, meaning that in its core there is only a single thread with a single loop for all operations, so when you do something like:
self.cursor.execute(...)
the entire system is waiting for a response from the database, including http requests that are waiting to be executed etc.
having said that, I suggest you'll check this code snippet https://github.com/riteshk/sc/blob/master/scraper/pipelines.py
using twisted.enterprise.adbapi.ConnectionPool is a little more complex than a simple blocking database access code but it plays well with the way scrapy uses io operations
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 9 years ago.
Improve this question
How can I create a client side database to store information of users on client side. Does anybody know of any tutorials or pointers? Which is the recommended database to use? My client is in .js and uses Django framework.
What you are asking for is called Web Storage and is part of HTML5.
http://diveintohtml5.info/storage.html
http://www.gwtproject.org/doc/latest/DevGuideHtml5Storage.html
However, many times when people SAY they need a client-side database, I ask them the details and it turns out that they don't really need client side storage at all, so proceed with caution.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
Is there a Python program where you can post a status update without going to the website itself?
Where or how do i get started?
You would wanna get started here, https://github.com/facebook/python-sdk
unless there's a library I don't know about.
You can checkout my fork of the python sdk. It's customized to work better with django.
You can check here on how to use it to authenticate a user.
After that you can use the python sdk to post a news entry.
fb.put_wall_post("hello")
Or do it yourself, it's only a matter of doing a POST request to http://graph.facebook.com/FBID/feed where FBID is the ID of the page or profile you want to publish to, more info in the facebook doc.