Python Forum

Full Version: gulp template with python?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
Hi, im about to start the develpment of a project using python,flask and sqlAlchemy, so i am looking for a nice template, and i have found one, but seems like it runs whih node js using gulp, i have already contact the template's support team, and they just told me they dont know flask, so my question is:

is it possible to run my python project using this template whit out any compability problem?

i have found a gulp alternative for flask, but seems a litle bit old, and of course it could be complicated to change the code in order to run the template with this gulp alternative.
gulp is a task runner and there no problem using it to task that work in Flask.
What's gulp?
  • Spinning up a web server
  • Reloading the browser automatically whenever a file is saved
  • Using preprocessors like Sass or LESS
  • Optimizing assets like CSS, JavaScript, and images
Can eg use it for optimizing assets like CSS,JavaScript and images.
They are still in same place as Flask severe them just that they optimized.
There are stuff that you don't let gulp to like spinning up a web server.
Flask has its own local development web server which can serve static files,and do reload of server change.
When moving away from local web server to a host(want to share with other) need to eg Gunigorn and Nginx(highly optimized to serve static files).

Have a tutorial here,it's show installing npm,gulp,bower..ect all in a virtual environment.
And running a template Freelancer in that virtual environment.
This is not needed as npm,gulp,bower can run on OS and just have virtual environment for Flask stuff,it's just that it can be nice to have all in one place.
Web-development is a messy place with all kind of tool needed or not Wink
(Jan-29-2019, 12:47 PM)snippsat Wrote: [ -> ]gulp is a task runner and there no problem using it to task that work in Flask.
What's gulp?
  • Spinning up a web server
  • Reloading the browser automatically whenever a file is saved
  • Using preprocessors like Sass or LESS
  • Optimizing assets like CSS, JavaScript, and images
Can eg use it for optimizing assets like CSS,JavaScript and images.
They are still in same place as Flask severe them just that they optimized.
There are stuff that you don't let gulp to like spinning up a web server.
Flask has its own local development web server which can serve static files,and do reload of server change.
When moving away from local web server to a host(want to share with other) need to eg Gunigorn and Nginx(highly optimized to serve static files).

Have a tutorial here,it's show installing npm,gulp,bower..ect all in a virtual environment.
And running a template Freelancer in that virtual environment.
This is not needed as npm,gulp,bower can run on OS and just have virtual environment for Flask stuff,it's just that it can be nice to have all in one place.
Web-development is a messy place with all kind of tool needed or not Wink
Hi, seems like im pretty lost of what gulp does, so tahnaks for the explanation, i would love to see the tutorial but seems like i am getting the "You do not have permission to access this page. This could be because of one of the following reasons:" message :/
(Jan-29-2019, 03:41 PM)IMuriel Wrote: [ -> ]i would love to see the tutorial but seems like i am getting the "You do not have permission to access this page.
Something went wrong with link,should work now link.
Quote:Hi, seems like im pretty lost of what gulp does, so tahnaks for the explanation,
Yes it can be confusing i talk about in tutorial,you see stuff like gulpfile.js,package.json,less ect in a template.
So when you find a template,there will be all of this stuff.
But then is usually already build,so you don't need to run guld,bower,npm to use template.
Whats needed usually is to get HTML/CSS linked up to Flask,to get template up and running.
(Jan-29-2019, 04:07 PM)snippsat Wrote: [ -> ]
(Jan-29-2019, 03:41 PM)IMuriel Wrote: [ -> ]i would love to see the tutorial but seems like i am getting the "You do not have permission to access this page.
Something went wrong with link,should work now link.
Quote:Hi, seems like im pretty lost of what gulp does, so tahnaks for the explanation,
Yes it can be confusing i talk about in tutorial,you see stuff like gulpfile.js,package.json,less ect in a template.
So when you find a template,there will be all of this stuff.
But then is usually already build,so you don't need to run guld,bower,npm to use template.
Whats needed usually is to get HTML/CSS linked up to Flask,to get template up and running.

Hi again, i am following your tutorial but when i type nodeenv -p i am getting a tracerback

Error:
nodeenv -p * Install prebuilt node (11.8.0) ....Traceback (most recent call last): File "C:\Python37\lib\runpy.py", line 193, in _run_module_as_main "__main__", mod_spec) File "C:\Python37\lib\runpy.py", line 85, in _run_code exec(code, run_globals) File "C:\Users\Ignacio Muriel\Desktop\programacion\python\comext\flask_boot\Scripts\nodeenv.exe\__main__.py", line 9, in <module> File "c:\users\ignacio muriel\desktop\programacion\python\comext\flask_boot\lib\site-packages\nodeenv.py", line 1076, in main create_environment(env_dir, opt) File "c:\users\ignacio muriel\desktop\programacion\python\comext\flask_boot\lib\site-packages\nodeenv.py", line 905, in create_environment install_node(env_dir, src_dir, opt) File "c:\users\ignacio muriel\desktop\programacion\python\comext\flask_boot\lib\site-packages\nodeenv.py", line 697, in install_node copy_node_from_prebuilt(env_dir, src_dir, opt.node) File "c:\users\ignacio muriel\desktop\programacion\python\comext\flask_boot\lib\site-packages\nodeenv.py", line 598, in copy_node_from_prebuilt callit(['copy', '/Y', '/L', src_exe, dst_exe], False, True) File "c:\users\ignacio muriel\desktop\programacion\python\comext\flask_boot\lib\site-packages\nodeenv.py", line 487, in callit % (cmd_desc, proc.returncode)) OSError: Command copy /Y /L "c:\users\ignacio mur...sk_boot\src\node.exe" "c:\users\ignacio mur...oot\Scripts\node.exe" failed with error code 1
To test it with Python 3.7 as it's 1.5 year since i made it.
It's nice to have all in one place,but it's not needed to run a template with Flask that i think you try to do.
# Make virtual environment 
E:\div_code
λ python -m venv flask_env

# cd in
E:\div_code
λ cd flask_env

# Activate  
E:\div_code\flask_env
λ E:\div_code\flask_env\Scripts\activate

# Here you most see (flask_env)
(flask_env) E:\div_code\flask_env
λ pip -V
pip 10.0.1 from e:\div_code\flask_env\lib\site-packages\pip (python 3.7)

# Upgrade pip
(flask_env) E:\div_code\flask_env
λ python -m pip install --upgrade pip
Collecting pip
  Downloading https://files.pythonhosted.org/packages/46/dc/3...../pip-19.0.1-py2.py3-none-any.whl (1.4MB)
    100% |████████████████████████████████| 1.4MB 2.4MB/s
Installing collected packages: pip
  Found existing installation: pip 10.0.1
    Uninstalling pip-10.0.1:
      Successfully uninstalled pip-10.0.1
Successfully installed pip-19.0.1

# Test pip it's 19.0
(flask_env) E:\div_code\flask_env
λ pip -V
pip 19.0.1 from e:\div_code\flask_env\lib\site-packages\pip (python 3.7)
So at this point virtual environment work.
Most stay in environment active (flask_env).
Then install Flask and nodeenv.
# install flask
(flask_env) E:\div_code\flask_env
λ pip install flask
Collecting flask
.....
Installing collected packages: click, itsdangerous, MarkupSafe, Jinja2, Werkzeug, flask
Successfully installed Jinja2-2.10 MarkupSafe-1.1.0 Werkzeug-0.14.1 click-7.0 flask-1.0.2 itsdangerous-1.1.0

# Install nodeenv
(flask_env) E:\div_code\flask_env
λ pip install nodeenv
Collecting nodeenv
  Downloading https://files.pythonhosted.org/packages/00/6e/e....../nodeenv-1.3.3.tar.gz
Successfully installed nodeenv-1.3.3

# Now use nodeenv -p
(flask_env) E:\div_code\flask_env
λ nodeenv -p
 * Install prebuilt node (11.8.0) ..... done.
 * Overwriting e:\div_code\flask_env\Scripts\activate.bat with new content
 * Overwriting e:\div_code\flask_env\Scripts\deactivate.bat with new content
 * Overwriting e:\div_code\flask_env\Scripts\Activate.ps1 with new content
symbolic link created for e:\div_code\flask_env\Scripts\nodejs.exe <<===>> node.exe
 * Install npm.js (latest) ...

# Test node
(flask_env) E:\div_code\flask_env
λ node -v
v11.8.0

# Test npm
(flask_env) E:\div_code\flask_env
λ npm -v
6.7.0
So it still work,try to follow it and do not skip a step.
(Jan-29-2019, 05:48 PM)snippsat Wrote: [ -> ]To test it with Python 3.7 as it's 1.5 year since i made it.
It's nice to have all in one place,but it's not needed to run a template with Flask that i think you try to do.
# Make virtual environment 
E:\div_code
λ python -m venv flask_env

# cd in
E:\div_code
λ cd flask_env

# Activate  
E:\div_code\flask_env
λ E:\div_code\flask_env\Scripts\activate

# Here you most see (flask_env)
(flask_env) E:\div_code\flask_env
λ pip -V
pip 10.0.1 from e:\div_code\flask_env\lib\site-packages\pip (python 3.7)

# Upgrade pip
(flask_env) E:\div_code\flask_env
λ python -m pip install --upgrade pip
Collecting pip
  Downloading https://files.pythonhosted.org/packages/46/dc/3...../pip-19.0.1-py2.py3-none-any.whl (1.4MB)
    100% |████████████████████████████████| 1.4MB 2.4MB/s
Installing collected packages: pip
  Found existing installation: pip 10.0.1
    Uninstalling pip-10.0.1:
      Successfully uninstalled pip-10.0.1
Successfully installed pip-19.0.1

# Test pip it's 19.0
(flask_env) E:\div_code\flask_env
λ pip -V
pip 19.0.1 from e:\div_code\flask_env\lib\site-packages\pip (python 3.7)
So at this point virtual environment work.
Most stay in environment active (flask_env).
Then install Flask and nodeenv.
# install flask
(flask_env) E:\div_code\flask_env
λ pip install flask
Collecting flask
.....
Installing collected packages: click, itsdangerous, MarkupSafe, Jinja2, Werkzeug, flask
Successfully installed Jinja2-2.10 MarkupSafe-1.1.0 Werkzeug-0.14.1 click-7.0 flask-1.0.2 itsdangerous-1.1.0

# Install nodeenv
(flask_env) E:\div_code\flask_env
λ pip install nodeenv
Collecting nodeenv
  Downloading https://files.pythonhosted.org/packages/00/6e/e....../nodeenv-1.3.3.tar.gz
Successfully installed nodeenv-1.3.3

# Now use nodeenv -p
(flask_env) E:\div_code\flask_env
λ nodeenv -p
 * Install prebuilt node (11.8.0) ..... done.
 * Overwriting e:\div_code\flask_env\Scripts\activate.bat with new content
 * Overwriting e:\div_code\flask_env\Scripts\deactivate.bat with new content
 * Overwriting e:\div_code\flask_env\Scripts\Activate.ps1 with new content
symbolic link created for e:\div_code\flask_env\Scripts\nodejs.exe <<===>> node.exe
 * Install npm.js (latest) ...

# Test node
(flask_env) E:\div_code\flask_env
λ node -v
v11.8.0

# Test npm
(flask_env) E:\div_code\flask_env
λ npm -v
6.7.0
So it still work,try to follow it and do not skip a step.

i just do it in my digitalocean droplen and it works, im changin the paths to the css of the html file,
the template taht i bought is this one https://themeforest.net/item/ubold-respo...t/13489470
and they said you need to do "gup build" in order to run the template, or at least that is in the documentation.
so i just need to have this template runnig, so im pretty confused on how can i accomplish this, but do you think this is the simplest way?
any way im ready to test this let me se if it works

Quote:i just do it in my digitalocean droplen and it works, im changin the paths to the css of the html file,
the template taht i bought is this one https://themeforest.net/item/ubold-respo...t/13489470
and they said you need to do "gup build" in order to run the template, or at least that is in the documentation.
so i just need to have this template runnig, so im pretty confused on how can i accomplish this, but do you think this is the simplest way?
any way im ready to test this let me se if it works

seems like im getting to the index.html, but whit out any style :/
[Image: 8oX9cdf]
(Jan-29-2019, 06:01 PM)IMuriel Wrote: [ -> ]they said you need to do "gup build" in order to run the template, or at least that is in the documentation.
so i just need to have this template runnig, so im pretty confused on how can i accomplish this, but do you think this is the simplest way?
You can also do a OS install of Node.js then you also get npm.
So running from OS.
E:\div_code\new
λ node -v
v10.11.0

E:\div_code\new
λ npm -v
6.4.1
The you can use npm to install gulp.
E:\div_code\new
λ npm install --global gulp-cli
C:\Users\Tom\AppData\Roaming\npm\gulp -> C:\Users\Tom\AppData\Roaming\npm\node_modules\gulp-cli\bin\gulp.js
+ [email protected]
added 236 packages from 154 contributors in 15.808s

E:\div_code\new
λ gulp --version
[19:24:52] CLI version 2.0.1
Quote: You can also do a OS install of Node.js then you also get npm.
So running from OS

yhea actually i can have the template working with node js, but seems like gulp creates his own server, so how can i access to the template with pyhon, maybe i should look for a simplest template? but i already bought this :/, my mistake by not reading carfully

thanks for all the help! you are awsome
You don't need to use server that gulp create.
After you have run gulp it's also generated HTML/CSS/JS/img files,this file you need to move to Flask static folder and link them up.

A do show how i link up in tutorial with template that i use there.
It can be different for your template,but it should give a hint on how to do it.
<link rel=stylesheet type=text/css href="{{ url_for('static', filename='vendor/bootstrap/css/bootstrap.min.css') }}" />
# Original link that i have comment out and done link to flask static folder 
<!--<link href="vendor/bootstrap/css/bootstrap.min.css" rel="stylesheet">-->
 
<script src="{{ url_for('static', filename='vendor/jquery/jquery.min.js') }}"></script>
<!--<script src="vendor/jquery/jquery.min.js"></script>-->
 
# images
<img src="static/img/portfolio/cake.png" class="img-responsive" alt="">
Pages: 1 2