简体   繁体   English

在一个应用程序中使用Eve和Flask

[英]Using Eve and Flask in one application

I want to provide REST interface and a single page JS-application for consuming the REST-service. 我想提供REST接口和一个使用REST服务的单页JS应用程序。 Is there a way to do both in one python app or should I start eve-app for providing REST and flask-app for providing HTML as two processes? 是否可以在一个python应用程序中同时执行这两种方法,还是应该启动eve-app以提供REST并启动flask-app以将HTML作为两个进程提供?

The Eve instance is a Flask app. Eve实例 Flask应用程序。 It's a subclass of Flask adding Eve-specific behavior. 它是Flask的子类,添加了Eve特定的行为。 Use that instance as you would a Flask instance. 与使用Flask实例一样使用该实例。

app = Eve()

@app.route(...)
...

If your flask app is only for serving static files, you don't even need a flask app. 如果Flask应用仅用于提供静态文件,则您甚至不需要Flask应用。 You may be able to directly serve static assets via Nginx 您也许可以通过Nginx直接提供静态资产

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM