Flask

Is there an easy way to distribute a Flask server as an executable?

时光怂恿深爱的人放手 提交于 2021-01-27 07:10:40
问题 I'm building some simple editors with Backbone.js, and I'm hoping to be able to distribute them as apps for users to edit content in a mostly client-side way (i.e., I don't want users to have to futz with setting up stuff like MySQL or Apache). So I was imagining a scenario like: User downloads a .zip file In the resulting opened folder, the user clicks index.html That opens in a browser Backbone app starts, stores data in localStorage The user can then export to CSV. Believe it or not, that

AWS Elastic Beanstalk - Flask App Cannot Import Custom Module

我只是一个虾纸丫 提交于 2021-01-27 06:33:19
问题 I am trying to host a Flask app on AWS Elastic Beanstalk in Python 3.6, but no matter what I try, the application's url leads to a 500: Internal Server Error. The structure of my app is as follows: myApp: -application.py -mytransformers.py -requirements.txt I took a look at the logs, and the separate python script I need that contains custom Scikit-learn transformers (mytransformers.py) cannot be found by wsgi: AttributeError: Can't get attribute 'MyTransformer' on <module '__main__' (built

AWS Elastic Beanstalk - Flask App Cannot Import Custom Module

情到浓时终转凉″ 提交于 2021-01-27 06:32:12
问题 I am trying to host a Flask app on AWS Elastic Beanstalk in Python 3.6, but no matter what I try, the application's url leads to a 500: Internal Server Error. The structure of my app is as follows: myApp: -application.py -mytransformers.py -requirements.txt I took a look at the logs, and the separate python script I need that contains custom Scikit-learn transformers (mytransformers.py) cannot be found by wsgi: AttributeError: Can't get attribute 'MyTransformer' on <module '__main__' (built

I am trying to learn Flask, but UserMixin seems not to work

末鹿安然 提交于 2021-01-27 06:31:35
问题 So to be more exact. I am currently learning Flask from Corey Schafers tutorial series and I am in the phase of Login Authentication, everything seemed to be fine, but then I got this error after trying to log in: AttributeError AttributeError: 'User' object has no attribute 'is_active' Traceback (most recent call last) File "C:\Users\panda\Desktop\HDD\Programs\Python3\Lib\site-packages\flask\app.py", line 2463, in __call__ return self.wsgi_app(environ, start_response) File "C:\Users\panda

“[CRITICAL] WORKER TIMEOUT” in logs when running “Hello Cloud Run with Python” from GCP Setup Docs

[亡魂溺海] 提交于 2021-01-27 05:14:20
问题 Following the tutorial here I have the following 2 files: app.py from flask import Flask, request app = Flask(__name__) @app.route('/', methods=['GET']) def hello(): """Return a friendly HTTP greeting.""" who = request.args.get('who', 'World') return f'Hello {who}!\n' if __name__ == '__main__': # Used when running locally only. When deploying to Cloud Run, # a webserver process such as Gunicorn will serve the app. app.run(host='localhost', port=8080, debug=True) Dockerfile # Use an official

How to get Flask/Gunicorn to handle concurrent requests for the same Route?

百般思念 提交于 2021-01-26 22:30:57
问题 tl;dr A method decorated with route can't handle concurrent requests while Flask is served behind a gunicorn started with multiple workers and threads, while two different methods handle concurrent requests fine. Why is this the case, and how can the same route be served concurrently? I have this simple flask app: from flask import Flask, jsonify import time app = Flask(__name__) @app.route('/foo') def foo(): time.sleep(5) return jsonify({'success': True}), 200 @app.route('/bar') def bar():

How to get Flask/Gunicorn to handle concurrent requests for the same Route?

倖福魔咒の 提交于 2021-01-26 22:27:05
问题 tl;dr A method decorated with route can't handle concurrent requests while Flask is served behind a gunicorn started with multiple workers and threads, while two different methods handle concurrent requests fine. Why is this the case, and how can the same route be served concurrently? I have this simple flask app: from flask import Flask, jsonify import time app = Flask(__name__) @app.route('/foo') def foo(): time.sleep(5) return jsonify({'success': True}), 200 @app.route('/bar') def bar():

如何用Python开发一个正经的网站?

杀马特。学长 韩版系。学妹 提交于 2021-01-26 11:13:48
后台回复‘ 0816 ’,加入Python技术交流群~ 前文回顾: 47页PPT:如何利用Python进行自动化办公? 有多少人像我一样,在学习编程之前,以为程序员都会修电脑? 又有多少人像我一样,在学习Python之前,觉得电脑上的APP/浏览器的WEB,神秘莫测,不知其所以然? Python作为一门编程语 言,已经被国内外许多公司用在网站开发中,国外有Google、YouTube、Instagram、Facebook,国内有豆瓣、知乎、春雨医生等。 今天给大家介绍一下,如何用Python进行网站开发~ 欢迎大家收藏学习、留言分享你的学习收获,也欢迎 将本文 转发给需要的朋友哦~ 1、Python Django开发博客系统(含Django入门教程、源代码、答疑群) https://www.bilibili.com/video/BV1t54y127y3 课程介绍:按照惯例, 第一套课程是入门级,主要作用是帮助你全面的看一下Python WEB开发到底是什么和入门级的案例操作。本套课程一共11个小时, 手把手带你搭建了一个个人网站。 也许有的同学会疑问:我不想做个人网站呀,我想做企业网站,我还想兼职赚钱呢~ 其实,企业网站不就是用户比较多的个人网站吗?您品品~ 2、最经典的Flask框架入门教程(40集) https://www.bilibili.com/video

Python如何开发网站?这两个不能少!

不打扰是莪最后的温柔 提交于 2021-01-26 10:27:09
  Python这门语言不用过多介绍想必大家都很清楚,Python不仅是一门简单易学的编程语言,同时适用于各大领域,无论数据分析、爬虫还是开发网站,Python几乎无所不能,那么Python如何开发网站?这两个框架你一定要学会。   Python主流的应用领域包含:Web开发、图形界面开发、系统网络运维、网络编程、科学数学计算、3D游戏开发等。   尤其是Web开发和数据科学计算方面,Python给予了特殊支持,也是应用最广泛的两大领域。   至于如何用Python来搭建网站?一定少不了Web开发框架,Python比较热门的Web开发框架就是Flask和Django,再结合其他方面的技术,就可以搭建一个开发网站。   Flask:属于轻量级框架,本身就是用Python语言编写的,兼容性很高,它采用Werkzeug Jinja2模板,搭配一系列extension功能,就可以开发一个简单的网站,十分适合初学者。   当然,如果你是一个小团队,开发网站复杂性不是很高,推荐大家使用Falsk,如果网站功能比较复杂,推荐大家使用Python的另外一个框架,Django。   Django是一个全能型的框架,也是Python Web开发使用最多的一个框架,十分具有学习的价值,如果初学者接触,刚开始可能很难,但是后期的话,只要你沉下气来好好学习,一定可以掌握好。 来源: oschina 链接:

python-flask handling application errors

ぐ巨炮叔叔 提交于 2021-01-25 06:35:03
问题 I've built a flask application and I try to catch unhandled application errors from my routes using the errorhandler decorator. I've a main.py which looks like this, app = Flask(__name__) api = Api(app) api.add_resource(Ping, '/ping') @app.errorhandler(500) def internal_server_error(error): print "caught internal server error" return "This page does not exist", 500 The route Ping is in another file, here is a sample version of the file class Ping(Resource): def get(self): raise return {}, 200