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 3 years ago.
Improve this question
I have written a python script that will connect to the oracle database using cx_oracle and gets data and performs some action on it.
I want to expose this python script as a Restful API. In google, I read that using flask we can deploy a Python script as a Web service.
What I am not clear
The flask itself behaves like a server?
Can I deploy the python Webservice in the Web logic server?
I want to deploy this Webservice in production. How can I provide security to this?
In another site, I read using Connection, Swagger we can implement it.
I am actually written using flask, flask-jsonpify, flask-sqlalchemy, flask-restful.
Please suggest which packages i need to use to deploy it as WebService.
Let me know in case of any other details needed. Thanks in advance for your suggestions and guidance.
Vijay
The flask itself behaves like a server?
It can
Can I deploy the python Webservice in the Web logic server?
Not unless you are using Jython as WebLogic runs Java applications
I want to deploy this Webservice in production. How can I provide security to this?
See next point
In another site, I read using Connection, Swagger we can implement it.
See next point
I am actually written using flask, flask-jsonpify, flask-sqlalchemy, flask-restful.
Sounds like you've done some research into what packages you need. Maybe find more to get swagger and security figured out
Please suggest which packages i need to use to deploy it as WebService.
Refer point 1. flask is all you need to run the web server
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 3 years ago.
Improve this question
I want to use tomtom web api for routing : https://developer.tomtom.com
every time I search how to use an API with django I get the restfull framework isn't that for building an API? If I can use it to work with an existing API if yes I want to know how?
Or the requests library for python would be enough?
You should definitely try requests package (link), it is totally sufficient for building any REST API client.
The Django package you've probably found is django rest framework which is used to build API interfaces. But what you want is not to build an API but make requests and integrate to and external API. Requests package is simple choice to do that.
I have found nice tutorial to API integration with python here. Good luck ;-).
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 4 years ago.
Improve this question
This is a beginner question. I post this here because I'm so lost that I realized I even don't know what to look for.
I'm a C++ developper and have a developed C++ app. On the other hand, I recently dug into web development and created a website using the Django framework, which I host on Heroku.
The flow of the website: a user enters input on the website, input files are uploaded to AWS S3 (I managed to get that working).
The part I'm lost: with the user input, I'd like to run the C++ app which I host on a Linux server (Codenvy). But I have no idea how to launch that application from the Django site which is served by Heroku. At least giving some keywords to enhance my web searches?
It sounds like what you need is to run a script on another server using python?
I'd suggest taking a look at Paramiko:
https://github.com/paramiko/paramiko/
It is a package to allow you to ssh into another machine and execute commands.
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
I'm in the early phases of designing and implementing a python web project that i want to be able to easily distribute.
Coming from a primary PHP and Perl world i know how i would do the project in those lanuages but I am trying to find the best method for python.
Not sure if it matters, but I'm thinking of using django as the web framework, but still exploring other frameworks.
What i'm looking for is best practices to be able to bundle my application and have users just install it using pip.
Would i be able to package the wen application like that even if it using django or is that not the way its normally done? Would they instead just download the code and set it up like it was any other tar ball of code?
I tried searching around for this but i find mostly information on people deploying there own projects.
Thanks
Dan
The answer depends of the size of your project.
If it's a plugin that could be integrated to any web site, so probally just an app in the project, it's quite easy check the page of the django's doc
If it's a full websitethen it's a little bit more complicated, since a django project depends on multiple settings that could differ from one system to an other I usually see the project being installed from a tar ball.
I've seen packages like django-admintools bundle multiple apps in one package, but the user still need to create a basic django project.
From what I know a full project cannot be install only by PIP.. the user always need to setup settings and the webserver (apache or nginx).
I hope this helped you.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
I decided to move from PHP and start using Django. I have successfully installed Python and Django on my web server. How can I just code my Python/Django program, throw it to the server over FTP, and run it without the need to SSH to the server and restart the django server every time?
What is the method to run Django codes exactly the same way we run PHP code (having the server running all the time if possible)?
My server runs CentOS 5.8 and Apache.
Edit:
Alright I really recommend this tutorial for who ever want to setup dJango on a web server , my recommendation after reading a lot of posts. Using dJango on Nginx web server is the most powerful performance you could get
https://code.djangoproject.com/wiki/DjangoAndNginx
You can't magically make Django run like PHP. Please look at the deployment documentation, as it's some of the best around.
You'll see step by step instructions for apache.
As for not having to SSH every time you load new code, the best tool for this job is fabric.
http://docs.fabfile.org/en/1.5/
Fabric is an amazing tool that is extremely easy to install and configure, which lets you run commands on your remote machine from your local machine.
For example, I simply type fab production deploy on my local machine to...
push git changes
pull git changes on remote
run pip install
migrate database
run collectstatic
finally "restart" apache - touching wsgi file.
I just want to stress that fabric is not like those deployment build scripts which are complicated. Fabric will literally take you 10 minutes to set up.
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 3 years ago.
Improve this question
I am completely new to Python-- never used it before today. I am interested in devloping Python applications for the web. I would like to check to see if my web server supports WSGI or running python apps in some way.
Let's say I have a .py file that prints "Hello world!". How can I test to see if my server supports processing this file?
FYI, this is a Mac OS X server 10.5. So I know Python is installed (It's installed on Mac OS X by default), but I don't know if it's set up to process .py files server-side and return the results.
BTW, I'm coming from a PHP background, so this is a bit foreign to me. I've looked at the python docs re: wgsi, cgi, etc. but since I haven't done anything concrete yet, it's not quite making sense.
A very basic WSGI application can look as follows:
def application(environ, start_response):
start_response('200 OK', [('content-type', 'text/html')])
return ['Hello world!']
Unfortunately, if you put this into helloworld.py on the server and then browse to URL/helloworld.py you will most likely see the code.
In general you need to add very specific configuration options to the server (or to a server configuration file) to get it to serve your python 'application' correctly. Given you are using mod_wsgi on Apache 2, a configuration could look as follows:
<VirtualHost *>
ServerName example.com
WSGIScriptAlias /server/location/address /path/to/helloworld.py
</VirtualHost>
Where /server/location/address is the endpoint of the URL you have to browse to.
This is because python WSGI catches all URLs passed to it, and pushes them to the same entry point (your application method/class). And from the information received in the parameters, the application must decide what page to return.
Since this information is so application specific there 'should' be a way to configure it on the server, however I have yet to come across a web-hosting configuration panel that allows the configuration of Python applications. This generally means you have to contact the server administrators and have them configure it for you.
However, in general, when you sign up for hosting the company generally has a page where they tell you exactly what is supported on their servers (generally: php, mysql) and how much space and bandwidth you are allowed. Thus if they do not list it on their site, it is highly likely they will not support it.
To get around this you can instead buy a VPS (Virtual Private Server) and then configure it however you want.
If you are new to Python and Python web application development, then ignore all the hosting issues to begin with and don't start from scratch. Simply go get a full featured Python web framework such as Django or web2py and learn how to write Python web applications using their in built development web server. You will only cause yourself much pain by trying to solve distinct problem of production web hosting first.