A simple CORS proxy in Python/Django to fetch content from remote sites without a CORS policy.
-
Run the package installation
pip install -r requirements-dev.txt
(python3 -m pip install -r requirements-dev.txt
if your default is python2)
- Start the local web server
python manage.py runserver
(python3 manage.py runserver
if your default is python2)
- You application will be served at http://localhost:8000/
You can modify the local port (current, 8000
) running the server with an extra parameter:
python manage.py runserver 0.0.0.0:LOCALPORT
(python3 manage.py runserver 0.0.0.0:LOCALPORT
if your default is python2)
-
Install Docker Desktop
-
Run
docker-compose up
from the application folder (docker-compose up -d
to leave it in the foreground anddocker-compose stop
to stop it) -
You application will be served at http://localhost:8000/
You can modify the local port (current, 8000
) changing docker-compose.yml
ports:
- 'LOCALPORT:8000'
You can request any URL using:
http://your.server/?url=https://your.url/request/
Once started your server, try for example, fetching http://ip-api.com/json/8.8.8.8:
http://localhost:8000/?url=http://ip-api.com/json/8.8.8.8
Sample result:
{"as":"AS15169 Google LLC","city":"Mountain View","country":"United States","countryCode":"US","isp":"Level 3 Communications","lat":37.4229,"lon":-122.085,"org":"Google Inc.","query":"8.8.8.8","region":"CA","regionName":"California","status":"success","timezone":"America/Los_Angeles","zip":"94043"}
This command line interface (CLI) helps to do some tasks related to Heroku.
You can install this tool following the official guide.
The main steps are:
1.- For MacOS, install Homebrew and run
brew install heroku/brew/heroku
2.- In Ubuntu/Debian based systems, install SnapCraftand run
sudo snap install --classic heroku
3.- For windows, download and execute the installer.
Create an account in Heroku.com to login (https://signup.heroku.com/)
You need an accout in Heroku.com to login.
heroku login [--interactive]
- Manual registration:
- After registation, go to https://dashboard.heroku.com/
- Create a new application using the button [Add] (https://dashboard.heroku.com/new-app)
- Using Heroku CLI:
- Run in your project:
heroku apps:create your-app-name
- Run in your project:
- Edit
ALLOWED_HOSTS
incorsproxy/settings.py
:
ALLOWED_HOSTS = [
'localhost',
'your-app-name.herokuapp.com'
]
Optionally, register your application as a python/django project:
heroku buildpacks:set heroku/python
Also, if you registered the applciation using the web dashboard, run this command, using the app name you previously registered in Heroku
heroku git:remote -a your-app-name
git push heroku master
Now your application is published at http://your-app-name.herokuapp.com/